Python learning
Python module
what is a module ?
a file containing a set of functions you want to include in your application .
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)
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
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