I created the following example to understand the instances in python
import time;
class test:
mytime = time.time();
def __init__(self):
#self
Let's look at those lines:
class test:
mytime = time.time();
Here you set class member value, which is calculated once when class definition is executed, so time.time()
is calculated once when module that contains class test
is loaded.
Every instance of the class test
will receive that precalculated value and you must override that value (e.g. in __init__ method), accessing it via self
(which is a special argument that stores reference to an instance), thus setting instance member value.