"in" for dicts (was: Python 2.1 function attributes)

Peter Hansen peter at engcorp.com
Mon Jan 29 00:12:07 EST 2001


Tom Satter wrote:
> 
> "Nathaniel Gray" <n8gray at caltech.edu> wrote in message
> news:3A7496A7.253B7B67 at caltech.edu...
> ...
> >
> > If I was to ask you, "Tim, is 'larch' in Webster's dictionary?" would
> > you reply, "Yes, it's under 'L'", or would you reply, "No, there's no
> > 'larch' section, just A,B,C,D,..."?
> >
> > (I know you'd _actually_ reply "Look it up yourself!" ;^)
> >
> > "in" just doesn't imply "has_key" for dictionaries.
> 
> Except that in Webster's dictionary, 'larch' IS a key with the definition
> (basically a tree) being the value.  So I would expect that 'larch' is IN
> Webster's.

I think almost everyone would agree that that much is valid.
(Perhaps not everyone, but almost.)

> ...  I would not say "Is 'larch' in
> Webster's dictionary", meaning is the word 'larch' used in any of
> definitions (values) in the dictionary, so at least in this case it is
> completely clear.

What if I asked the following:

  Is "larch \Larch\, n. [Cf. OE. larege (Cotgrave), It. larice, 
      Sp. larice, alerce, G. l["a]rche; all fr. L. larix, -icis, 
      Gr. (?).] (Bot.) A genus of coniferous trees, having 
      deciduous leaves, in fascicles (see Illust. of Fascicle)."
    in Webster's dictionary?

The answer, as with just "larch", is "yes".  This happens to be
one of the definitions, however.  Isn't it in the dictionary
just as much as its key is?

I'm playing Devil's advocate a bit, because, as with 'print >>', 
I think I would actually *like* this particular addition.
In fact, as with 'print >>' I have several times thought
"dang, how come I can't do this already?".

Nevertheless, I can see why some people might be bothered
on one level by arbitrarily saying this refers to _keys_ 
instead _values_.



More information about the Python-list mailing list