Am Montag, den 04.07.2005, 20:25 -0400 schrieb Roy Smith:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> > Should we *really* be encouraging newbies to mess with globals() and
> > locals()? Isn't that giving them the tools to shoot their foot off before
> > teaching them how to put shoes on?
> 
> Why risk damaging perfectly good footwear?
> 
> But, seriously, I agree with you.  The cannonical way to tell if a variable 
> exists in Python is to try to access it and catch any resulting NameError.
Although it should be said that this goes only for variables. obj.value
isn't such a beast (even if some newbies might think so), and would
throw an AttributeError.

Another thing to consider when it comes to footwear: Ruining it once and
enduring the resulting discomfort teaches quite well. And leaves a
respect for the "magic" features of Python that stays the rest of one's
life :)

So I think every newbie at some time of his/her learning process should
probably have fun with all the cool features of Python (be it globals(),
assigning to __builtins__, __getattr__ and derived classes, or what
ever ;) ). Playing alone is not enough, but playing and living to
maintain the code afterwards is very educative ;)
OTOH, perhaps for me it was teaching more, because I have been forced to
maintain by first bigger python application almost for a decade. One
learns quite a bit about software engineering this way ;)

Andreas

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

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

Reply via email to