Status of PEP's?

Bjorn Pettersen BPettersen at NAREX.com
Thu Mar 7 11:31:18 EST 2002


> From: Alan Daniels [mailto:daniels at mindspring.com] 
> 
> Michael Chermside <mcherm at destiny.com> wrote in message 
> news:<mailman.1015421793.13369.python-list at python.org>...
> 
> The objection you quoted was from me originally, so I feel 
> compelled to respond to it here.
> 
[snip]
> 
> There's still some MAJOR problems I see with PEP 276:
> 
> 1) Right now, we have complete orthogonality between "for" 
> and "if". "for i in seq:" will be called for each value where 
> "if i in seq:" is true. Adding "for i in 5" destroys this.

This surely doesn't have to be true. The for loop implicitly calls
iter(seq) to get an iterator, and the if statement first tries to call
__contains__ when faced with an 'in' test. It's trivial to implement a
__contains__ method for type int that preserves the orthogonality.
You're right though that the PEP should probably say whether it also
proposes to implement __contains__ for type int.

-- bjorn
 




More information about the Python-list mailing list