[Twisted-Python] SMTP patch

Magnus Lyckå magnus at thinkware.se
Fri May 23 19:05:38 MDT 2003


Peter Hansen wrote:
>Andrew Bennetts wrote:
> >
> > Oops!  As you imply, that should've been "200 <= code < 300".  I still 
> don't
> > like the idea of constructing 100 integers, even lazily, just to test
> > bounds, though.
> >
> > Of course, if the status code was left as a string, then you could 
> simply do
> > "if code.startswith('2'):"  :)
>
>if str(code).startswith('2'):  ??

It's much faster to do:

if code // 100 == 2:

That would also stop strange codes like 25 or 2300 (if they might
ever appear though some future mystery) to be mistaken as in the
range 200-299.


--
Magnus Lycka (It's really Lyckå), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program 





More information about the Twisted-Python mailing list