Skip to content

Instantly share code, notes, and snippets.

@juandesant
Created March 17, 2013 19:37
Show Gist options
  • Save juandesant/5183257 to your computer and use it in GitHub Desktop.
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.
# 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