[Tutor] assert

python-tutor@toddmaynard.com python-tutor at toddmaynard.com
Fri Dec 23 12:55:41 CET 2005


Try this:

>>>a=myClass()
>>>b=myClass()
>>>a.howmany()
>>>a.count=0
>>>del a

Does this help clear things up?


Todd Maynard

On Friday 23 December 2005 06:18, shivayogi kumbar wrote:
> class myClass:
>                         count = 0
>                          def __init__(self):
>                                   myClass.count = myClass.count + 1
>                           def __del__(self):
>                                    myClass.count =myClass.count -1
>                                     assert myClass.count>0
>                           def howmany(self):
>                                    return myClass.count


More information about the Tutor mailing list