Richard Brodie said unto the world upon 2005-04-12 04:56:
"Brian van den Broek" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


I'm a hobbyist and still learning, but the claim the try/except is
"lousy Python" surprise me a bit.


I think it wasn't the use of try/except as such. It's more that
if you're the developer you ought to know whether variables
are defined or not. It might be a sign you're using global
variables more often than would be considered good style in
Python.

Richard and STeVe,

thanks for the replies :-)

I see your point, Richard. Though where it has come up for me most often is code internal to a class, where I only need a "real" value for a class attribute in some cases, depending upon the inputs to the class __init__. "Globals are bad" is one lesson I have learned :-)

STeVe stressed that the try/except solution is only really appropriate for cases where the failure to have the variable defined is quite rare. Even though wary of "the root of all evil ... " that seems a good reminder. Thanks.

Best to all,

Brian vdB

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to