How to write a python module?

PythonServer Side ProgrammingProgramming

A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py

 create then write the following function as its content:

 def hello_world():
    print "Hello world"

 Now create another file in the same directory called Write the following as its contents:

 import helloworld

 We created the helloworld module and imported it in Then we used the function from Creating many modules in the working directory can create a lot of clutter. You can use packages to neatly group multiple modules together. You can read about how packages are created and used in detail here:

Published on 19-Dec-2017 14:00:59