[Python-ideas] "on" statement

Robert Kern robert.kern at gmail.com
Thu Apr 1 22:06:18 CEST 2010


On 2010-04-01 14:04 PM, Oleg Broytman wrote:
> On Thu, Apr 01, 2010 at 11:54:53AM -0700, Bruce Leban wrote:
>>      foo is in bar     = hasattr(foo,bar)
>
>     foo is in bar
>
> is currently a valid and widely used expression. It means
> bar.__contains__(foo).

No, it's not.

 >>> 1 is in range(5)
   File "<stdin>", line 1
     1 is in range(5)
           ^
SyntaxError: invalid syntax

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-ideas mailing list