Search This Blog

Wednesday, June 29, 2011

Getting class from class variable

If I have a class variable being passed to a function, is there a way that I can get the class that the variable is from?





class someclass:
def __init__(self):
self.somevariable='somevalue'

def somefunction(self):
print('gotta get here')

def someotherfunction(somevariable):
somevariable.needparentclasshere.somefunction()

myclass=someclass()
someotherfunction(myclass.somevariable)#this needs to print 'gotta get here'



http://bit.ly/mNClir

No comments:

Post a Comment