How to avoid "f.close" (no parens) bug?

Michael Pyle mpyle at legato.com
Wed Feb 11 18:01:51 EST 2004


We used this to test whether the application was running in the development
environment or "frozen" into an executable. That knowledge in turn was used
to decide whether to create the "Debug" menu and allow certain command line
parameters. Very handy.

try:
	sys.frozen
except AttributeError:
	options.append( 'debug-on' )

--mike
	

-----Original Message-----
From: Neil Hodgson [mailto:nhodgson at bigpond.net.au] 
Sent: Wednesday, February 11, 2004 1:28 PM
To: python-list at python.org
Subject: Re: How to avoid "f.close" (no parens) bug?


Batista, Facundo:

> Why "appears"?
>
> There is any case when f.close, or bar or something like "not a call 
> to a function (there is no ')'), with no '=' at the left or at the 
> right" has
any
> effect?

   I have seen this used as a test. Simplified:

try:
    f.close
except AttributeError:
    f.close = makeAMethod()

   Neil


-- 
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040211/a39d84a4/attachment.html>


More information about the Python-list mailing list