[Python-ideas] "on" statement

Oleg Broytman phd at phd.pp.ru
Thu Apr 1 22:29:45 CEST 2010


On Thu, Apr 01, 2010 at 03:06:18PM -0500, Robert Kern wrote:
> 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

   Ah, sorry, you are right. But that shows why the proposed syntax is bad
- it's too similar to an existing one.

Oleg.
-- 
     Oleg Broytman            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.



More information about the Python-ideas mailing list