On Jul 29, 2011, at 9:22 PM, Steven D'Aprano wrote:

> Billy Mays wrote:
> 
>> Is xrange not a generator?  I know it doesn't return a tuple or list, so
>> what exactly is it?  
> 
> xrange pre-dates generators by approximately forever. It returns a
> special "xrange object", which generates values suitable for use in
> for-loops using the old __getitem__ protocol.
> 

interesting...I never really thought about this.  Is there a reason that it 
wasn't reimplemented when generators came out?  Is there a use-case for the 
current implementation that wouldn't work as a generator?


                                bb
-- 
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to