Check in for an instance of a class
Aahz Maruch
aahz at panix.com
Tue Dec 25 23:06:58 EST 2001
In article <59f8895f.0112251925.26c43cc at posting.google.com>,
Ben Graham <musk_ben at yahoo.com> wrote:
>
> I need to check whether an instance of a particular class exists, in
>its __init__(...). Assuming that the module containing the class may
>or may not be imported, what are the my options? (As far as possible,
>I would like to contain the test in the class completely). And, yes, I
>need a pre-2.2 solution.
Just use a class variable:
class C:
InstanceCreated = None
def __init__(self):
if C.InstanceCreated is None:
...
C.InstanceCreated = 1
else:
...
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
Tenth Virtual Anniversary: 6 days and counting
More information about the Python-list
mailing list