| |
- C
class C |
|
A class to demonstrate class variables in Python
Objects of class C have one private object attribute __data.
All objects of class C share the same class variable C.instances
which keeps track of the total number of instances made of C. |
|
- __init__(self, value=0)
- Constructor
- __str__(self)
- __str__() -> String
Returns the string representation of the object.
__str__(obj) will be called by "print obj" .
- getInstances(self)
- getInstances() -> int
return the number of instances made of C
- getValue(self)
- getValue() -> anyType
Get the "value" of this instance found in the private variable
__data. Note how ALL read access to __data should be through
getValue() !
- setValue(self, value)
- setValue(value:anyType)
Set the "value" of the C instance in the private variable __data.
Note how ALL write access to __data is done through setValue(),
even in __init__ !
| |