hi,
I have a small problem I think the following code explains what I am trying to do:
*****************************************
class TEST:
def __init__ (self):
print "INSTANCE"
def A (self):
self.a = 'AZ'
def B (self):
print self.a
if __name__ == '__main__':
test = TEST()
test.B()
******************************************
I am trying to get the value of self.a in def B() though it is being declared in def A(). Currently it doesn't work and gets an error:
AttributeError: Azeem instance has no attribute 'a'
Now is there a way to get the value of self.a in def B() without declaring self.a in __init__() i.e. any way to get to that value using any class reference or anything.
What I want to do is that create multiple lists at runtime in different methods. I am not sure ahead how many lists I need to create as it all depends on the data in the input-file. I have different methods that populate the relevant lists. That's a small picture of the code I am working. Any help is appreciated.
Thanks
I have a small problem I think the following code explains what I am trying to do:
*****************************************
class TEST:
def __init__ (self):
print "INSTANCE"
def A (self):
self.a = 'AZ'
def B (self):
print self.a
if __name__ == '__main__':
test = TEST()
test.B()
******************************************
I am trying to get the value of self.a in def B() though it is being declared in def A(). Currently it doesn't work and gets an error:
AttributeError: Azeem instance has no attribute 'a'
Now is there a way to get the value of self.a in def B() without declaring self.a in __init__() i.e. any way to get to that value using any class reference or anything.
What I want to do is that create multiple lists at runtime in different methods. I am not sure ahead how many lists I need to create as it all depends on the data in the input-file. I have different methods that populate the relevant lists. That's a small picture of the code I am working. Any help is appreciated.
Thanks