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

Paul Prescod paul at prescod.net
Thu Feb 12 18:23:16 CET 2004


Michael Pyle wrote:

> 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' )

A cleaner and probably more efficient way of doing this is:

if not hasattr(sys, "frozen"):
	options.append("debug-on")

  Paul Prescod








More information about the Python-list mailing list