Module: function_set.py
def print_function( name ):
print "hello, %s" % name;
return
Class: Person.py
class Person:
'''
classdocs
'''
name = "";
age = 0;
gender = "Unknown";
def __init__(self, name, age, gender):
'''
Constructor
'''
self.name = name;
self.age = age;
self.gender = gender;
def print_info(self):
print "Name: %s, Age: %d, Gender: %s" % (self.name, self.age, self.gender);
import:
from function_set import print_function
from Person import Person
print_function("tes1t");
p = Person("John Smith", 28, "Male");
p.print_info();
Note:
Each package in Python is a directory which MUST contain a special file called __init__.py.
This file can be empty, and it indicates that the directory it contains is a Python package,
so it can be imported the same way a module can be imported.
http://www.learnpython.org/Modules_and_Packages