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.
···
On 2008-05-07, Chester <wxpythoner@gmail.com> wrote:
--
Grant Edwards grante Yow! ... the HIGHWAY
at is made out of LIME
visi.com JELLO and my HONDA is a
barbequeuedOYSTER! Yum!
If the only problem were that 'has_key' tells that my_dictionary is a
dictionary, and 'in ' doesn't, to type if and when need be
'type(my_dictionary)' does not seem to go wandering unduly.
No, not unduly, but it's another action you have to take to verify
what the hell is my_dictionary. You may need to restart your app just
to put a "print type(my_dictionary)" to see what it is. You don't have
this with the has_key method, as you recognize it with a single glance
that my_dictionary is a dict.
By the way, if
'orange' is a value and you type «'orange' in my_dictionary», the answer you
get is False.
Uhm, so what? You get the same with has_key, and the same behaviour
with the "in" construct for lists, tuples and whatever you can think
of which supports the "in" construct.
Anyway, this thread has gone for way too long. It has nothing to do
with wxPython. I'll follow the others' advice about Chester. Game Over .
···
On Thu, May 8, 2008 at 11:40 AM, raffaello wrote:
2008/5/8 Andrea Gavana <andrea.gavana@gmail.com>:
On Thu, May 8, 2008 at 1:42 AM, Grant Edwards wrote:
> On 2008-05-07, Chester <wxpythoner@gmail.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.
And, moreover, if you don't know that my_dictionary is a dictionary,
the "in" statement can be misleading, as it applied to lists too (and
tuples and possibly other things). If the dictionary is called
dataValues, for example, what are you going to understand if you read
something like:
if "orange" in dataValues:
? If the code is not from you and it's not adequately commented, you
have to go wandering around to find what the hell dataValues is. So,
the has_key is going to disappear in 3.0: of all the changes the BDFL
and the board of gurus could have implemented this is possibly the
least interesting, least useful and least "code-cleaning-oriented" one
they could think of.
<div class="moz-text-flowed" style="font-family: -moz-fixed">Robin Dunn wrote:
Chester wrote:
You people are so f****** blind...
Strike one
What, the f***, is wrong with you?!
Strike two
You stupid ***!
Strike three, you're outta here! (Address blocked in mailman).
It wasn't the words, but the attitude that offended, and the complete lack of netiquette that annoyed. It is a serious matter to ban someone, but I stand behind you in this case. Thanks for making the decision publicly!
Paul
</div>
It's not just those posts where Chester was swearing...he was giving erroneous information to newbies too and causing general confusion.
Robin Dunn wrote:
...
It wasn't the words, but the attitude that offended, and the complete lack of netiquette that annoyed. It is a serious matter to ban someone, but I stand behind you in this case. Thanks for making the decision publicly!
I guess it is time to laugh, especially after he is gone. Good one, besides blond jokes...
Bruce
This reminds me of…
Many years ago a man and woman married at church. They were poor and lived in the country so they rode home from the church following their wedding in a wagon pulled by a donkey. Along the way the donkey stumbled and fell. The man said, “That’s one.” The donkey picked himself up and started pulling the wagon again. A short while later the donkey stumbled and fell again. “That’s two,” the man said. Again the donkey picked himself up. Again the donkey started pulling the wagon. And, a little further down the road, the donkey stumbled and fell again. The man said, “That’s three.” He climbed from the wagon, picked up his rifle, unhitched the donkey, and led the donkey into the woods. There was a gun shot and the man returned without the donkey. The bride was beside herself in disbelief. As he returned to the wagon she started in on him. “What are you doing? How are we going to get home? And that’s your only donkey. Who’s going to pull the plow on the farm?” The man climbed into the wagon seat and said, “That’s one.”