你想将你的代码组织成由很多分层模块构成的包:
graphics/
__init__.py
primitive/
__init__.py
line.py
fill.py
text.py
formats/
__init__.py
png.py
jpg.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class line:
def __init__(self, x, y):
self.x = x
self.y = y
from graphics.primitive.line import *
s=line('a','b')
print s
print s.x
print s.y