Mastery14

Creating and using a Python module

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

Example:

  • Create “hello.py” then write the following function:
def helloworld():
   print "hello"

import hello
hello.helloworld()
>>>'hello'

AWESOME PAGE

14 1014

CC BY 4.0 Mastery14 by Joel Erles is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.