mshiltonj a écrit : > On Jul 8, 8:29 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: >> On Jul 8, 2:11 pm, mshiltonj <[EMAIL PROTECTED]> wrote: > >> I have some comments on the Pythonicity of your suggestions. Same >> assumption, object attr is a unique key of some sort. How to create >> the dict of objects, and how to retrieve an object by key. >> >> -- Paul > > I was probably being overly helpful, in a bad way. I'm new to python, > I'm not very pythonic yet, and still learning the python idioms. > > Not sure why I slipped into the habit of testing for None, though. :-( > > Probably a perl thing, where I'm regularly testing for defined-ness. > "if ($foo)" is different than "if (defined $foo)"
I'm not sure about the exact meaning of "defined-ness" in Perl, but in Python, trying to access a non-existing name - which is not the same thing as a name bound to None - will raise a NameError. And while we're at it, you definitively don't need the parens around the test. -- http://mail.python.org/mailman/listinfo/python-list