On Mar 27, 10:08 pm, [EMAIL PROTECTED] (Alex Martelli) wrote:
>
> Forget all the naming silliness and use self.__class__.printOnce
> instead.
>
> Alex
I tried self.__class__.printOnce and that worked. Thanks for your
help.
--
http://mail.python.org/mailman/listinfo/python-list
<[EMAIL PROTECTED]> wrote:
...
> class Outer:
> class Inner:
> printOnce = True
>
> def __init__(self):
> if Outer.Inner.printOnce:
> print 'Printing once.'
> Outer.Inner.printOnc
The following code will print a message only once:
class PrintOnce:
printOnce = True
def __init__(self):
if PrintOnce.printOnce:
print 'Printing once.'
PrintOnce.printOnce = False
first = PrintOnce()
second = PrintOnc