{.headerlink}Python learning {#Python-learning}
{.headerlink}Python module {#Python-module}
{.headerlink}what is a module ?
a file containing a set of functions you want to include in your
application .
{.headerlink}create a module
to create a module just save the code you want in a file with the file
extension .py
save this code in a file named mymodule.py
def hello (name):
print(“hello ,” + name)
{.headerlink}use a module
now we can use the module we just created by using the **import **
statement:
import the module named mymodule , and call the hello
function
import mymodule
mymodule.hello(“malu”)
note: when using a function from a module, use the syntax:
module_name.function_name
{.headerlink}variables in module
the module can contain functions, as already described ,but also
variables of all types
the module can contain functions, as already described,but also
variables of all types
the module can contain function