Python modules are easy to create and imported in to your python program.
How to create a module?
The python program itself can be called as a python module. All the function which you find that can be grouped together can be put into the file. Here a simple example to print the text on display is used and called as techinfotalks.
#!/usr/bin/python # Python Module def func_hi(): print "Welcome to the module" #End
How to use the module in program?
You just import the module created by calling the import.After that directly call the function which ever you need.The module named techinfotalks is imported as named as ti.
#!/usr/bin/python import techinfotalks as ti print "Calling funcion in module" ti.func_hi() #End of program
Comments
Post a Comment