function to check whether a variable already exists?
Graham Guttocks
graham_guttocks at yahoo.co.nz
Tue May 1 12:43:40 EDT 2001
Can anyone tell me how to wrap the following in a function as to
avoid typing this try, except sequence for every variable whose
existence I want to check?
For example,
try:
if NEWSRC:pass
except NameError:
NEWSRC = os.path.expanduser("~/.newsrc")
It seems tricky, because you can't just pass a function NEWSRC because
if it doesn't first exist NameError will immediately be raised.
Regards,
Graham
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
More information about the Python-list
mailing list