import time
timestart = time.time()
# code to measure here
print time.time() - timestart, "seconds"
You can also try time.clock(). It is said to be more accurate.
Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Sunday, August 7, 2011
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
class Sample:
def __init__(self, max):
self. max = max
....
sampleinstance = Sample(2)
max = sampleinstance.max
Subscribe to:
Posts (Atom)