Ahoj, nestacilo by neco takoveho?

    >>> class MyClass:
   ...
   ... counter = 0
   ...
   ... def __init__(self):
   MyClass.counter += 1
   ... MyClass.counter += 1
   ...
   ... def __del__(self):
   ... MyClass.counter -= 1
   ...
    >>>
    >>> print MyClass.counter
   0
    >>>
    >>> c = MyClass()
    >>> print MyClass.counter
   1
    >>>
    >>> d = MyClass()
    >>> print MyClass.counter
   2
    >>>
    >>> c = MyClass()
    >>> print MyClass.counter
   2
    >>>
    >>> del c
    >>> print MyClass.counter
   1
    >>>
    >>> del d
    >>> print MyClass.counter
   0
    >>>

Leos

--
----
Leos Pol
SW Engineer
Radiante Corp.

If it can be imagined,
we can implement it


Xeleos wrote:
Ahoj, dá se nejak zjistit, kolik je aktivních instancí daného
objektu a získat na ne reference? Ješte by me zajímalo, zda se
dá zjistit kolik existuje na  instanci odkazu a z jakých objektu?
Pred nedávnem jsem se ptal, zda jde zjistit velikost objektu v
pameti, nedostalo se mi odpovedi, tak to zkouším ješte jednou.
Díky moc

------------------------------------------------------------------------

_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python

_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python

Odpovedet emailem