ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxpython-users
wxpython-users
[wxpython-users] Re: has_key() method versus the 'in' statement
by Grant Edwards other posts by this author
May 7 2008 5:45PM messages near this date
[wxpython-users] Re: Getting Tired | Re: [wxpython-users] Re: has_key() method versus the 'in' statement
On 2008-05-07, Chester <wxpythoner@[...].com>  wrote:


>  if my_dictionary.has_key("orange"):                      UGLY

I disagree.

>  if "orange" in my_dictionary:                                 CLEAN

I disagree.

In the first example it is obvious to the reader that you're
checking to see if my_dictionary contains "orange" as a key.
In the second example it is not obvious whether the code is
checking whether my_dictionary contains "orange" as a key or as
a value.

I find the first version more obvious.

-- 
Grant Edwards                   grante             Yow!  ... the HIGHWAY
                                  at               is made out of LIME
                               visi.com            JELLO and my HONDA is a
                                                   barbequeuedOYSTER! Yum!

_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Grant Edwards
Andrea Gavana
Raffaello
Andrea Gavana
Chester
Robin Dunn
Peter Damoc
Ft
Paul McNett
Werner F. Bruhin
Raph
Mike Driscoll

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved