Created
March 17, 2013 19:37
-
-
Save juandesant/5183257 to your computer and use it in GitHub Desktop.
Possible outline of a module, to allow easier access to classes and methods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# module layout: | |
# + mymodule | |
# | | |
# +---__init__.py | |
# | | |
# +---class1.py | |
# | | |
# +---class2.py | |
# | | |
# +---otherclasses/ | |
# | | |
# +--- __init__.py | |
# | | |
# +--- iamaclass.py | |
#Listing ./mymodule/__init__.py | |
from class1 import Class1 | |
from class2 import Class2 | |
#Listing ./mymodule/class1.py | |
class Class1(object): | |
"""The first class""" | |
def __init__(self, myproperty): | |
super(Class1, self).__init__() | |
self.myproperty = myproperty | |
def get_property(self): | |
return self.myproperty | |
#Listing ./mymodule/class2.py | |
class Class2(object): | |
"""The first class""" | |
def __init__(self, prop1=None, prop2=None): | |
super(Class2, self).__init__() | |
self.prop1 = prop1 | |
self.prop2 = prop2 | |
def get_properties(self): | |
return [self.prop1, self.prop2] | |
#Listing ./mymodule/otherclasses/__init__.py | |
from iamaclass import IamAclassListing ./mymodule/otherclasses/iamaclass.py | |
class IamAclass(object): | |
"""docstring for i_am_a_class""" | |
@staticmethod | |
def static_method1(): | |
return 3.141592654 | |
@staticmethod | |
def static_method2(x): | |
return 3.141592654+x | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment