Monday, July 11, 2011

Accessing instance variable in Python

To access a Python instance variable outside the class:

class Sample:
def __init__(self, max):
self. max = max
....

sampleinstance = Sample(2)
max = sampleinstance.max

No comments:

Post a Comment