Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- os.system('cls')
- class other_class(object):
- #An individual object class
- #note, this is instantiated under general_instance.__init__()
- def implicit(self):
- print " other_class.implicit()"
- def altered(self):
- print " other_class.altered()"
- class general_class(object): #An individual object that calls another_class object
- def __init__(self): #instantiates and includes other_class() as 'self.other'
- self.other_class = other_class()
- def method(self):
- print " general_class method()"
- print " #general_class has a 'method()' that does not relate to other_class()"
- def implicit(self):
- print " self.other_class.implicit()"
- print " #general_class.implicit() hands off call to other_class.implicit() via 'self.other'"
- print " #this results in:"
- self.other_class.implicit()
- def altered(self):
- print " general_class.altered()"
- print " #general_class has an altered()"
- print " self.other_class.altered()"
- print " #general_class calls other_class.altered() via 'self.other'"
- self.other_class.altered()
- print " general_class.altered()"
- print " #general_class.altered() continues after 'self.other' call"
- class display(object):
- def general_instance(self):
- print "display general_instance()of general_class() calls:"
- print ""
- print "general_class initializes it's settings with an '___init___' method"
- print" def __init__(self):"
- print" self.other_class = other_class()"
- print" #instantiates and includes other_class() as 'self.other'"
- print ""
- print "'general_instance.method()' results in:"
- general_instance.method()
- print""
- print "'general_instance.implicit()' results in:"
- general_instance.implicit()
- print " #unlike a parent/child, other_class methods cannot be called unless general_class has a method to hand off the call"
- print""
- print "'general_instance.altered()' results in:"
- general_instance.altered()
- print""
- general_instance = general_class()
- show = display()
- show.general_instance()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement