[Twisted-Python] SMTP patch

Bob Ippolito bob at redivi.com
Fri May 23 00:46:09 EDT 2003

On Thursday, May 22, 2003, at 23:02 America/New_York, Jp Calderone 

>     Interestingly, there was a thread on PyPy-dev on this subject.  I 
> think
> I agree with the line of thinking that says "x in y" expresses the 
> intent
> more accurately and at a higher level than "a <= x < y".  xrange() is 
> a hack
> though, so I would use range() :)

Only because in this particular case all valid x are exactly 
representable by an integer .. there are plenty of x (floats or 
otherwise) that satisfy a <= x < y that aren't in the set of integers 
[a, y>

Personally, I think there should be a hybrid between a list and a 
generator (kinda like xrange but more magical) returned whenever you do 
a range or a list comprehension or a slice unless you explicitly ask 
for all of the values to be calculated.. or at least an aesthetically 
pleasing way to do things like that.. and no, itertools and friends do 
not count, especially because generators can't support __getitem__ and 
__len__ when the user wants it to.  You could make a ton of VM 
optimizations like that, especially for objects like range(a, b).  for 
example, it could support __contains__ which would simply do a <= x < y 
(or the equivalent for a stepped range), reverse and sort would 
essentially be a no-op until an unordered append or insert happens, etc.


More information about the Twisted-Python mailing list