Class with in class in python -
i have classex.py file:
class class1: def method1(): print 'stack1' def method2(): print 'over1' def method3(): print 'flow1' class class2: def method1(): print 'stack2' def method2(): print 'over2' def method3(): print 'flow2' class class3: def method1(): print 'stack3' def method2(): print 'over3' def method3(): print 'flow3'
i want access classex
file class import file how access in various classes .
for example:
import classex print class1.method1() print class2.method2()
my expect output stack1
, over2
class class1: def method1(self): # instance passed implicity first arg print 'stack1' def method2(self): print 'over1' def method3(self): print 'flow1' class class2: def method1(self): print 'stack2' def method2(self): print 'over2' def method3(self): print 'flow2' class class3: def method1(self): print 'stack3' def method2(self): print 'over3' def method3(self): print 'flow3'
>>> import classex >>> c = classex.class1() # instance of class1 >>> c.method1() stack1
Comments
Post a Comment