PEP 260: simplify xrange()

Christopher A. Craig com-nospam at ccraig.org
Thu Jun 28 14:01:22 CEST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Grant Griffin <not.this at seebelow.org> writes:
> [stuff about str]
> which, coincidently, looks a lot more like:
> 
> 	>>> repr(xrange(5))
> 	'xrange(5)'
> 
> than:
> 
> 	>>> str(range(5))
> 	'[0, 1, 2, 3, 4]'
> 

str(xrange(5)) actually looks _exactly_ like repr(xrange(5)), probably
because str() falls back to repr() if it is undefined.  Coincidentally
(or not), str(range(5)) look exactly like repr(range(5)) as well
(probably for the same reason).

The reason that they don't look alike is because when range(5) is
executed it returns [0, 1, 2, 3, 4] whereas xrange(5) returns an
xrange object.


- -- 
Christopher A. Craig <com-nospam at ccraig.org>
"There's no reason the CEO has to write C code." Bill Gates
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard <http://www.gnupg.org/>

iEYEARECAAYFAjs7HIAACgkQjVztv3T8pzs/UACgrdAmcsnAUHksU3GOXbu03ijA
TvMAoNWSmtnLItHb1CuYgM3CwwTc3Mou
=R19I
-----END PGP SIGNATURE-----



More information about the Python-list mailing list