xrange question

Tim Peters tim.one at home.com
Wed May 9 03:19:39 EDT 2001


[assorted luminaries blame me for their inability to make a correct
 choice between "range" and "xrange" -- thanks!
]

Here's a useful addition for your sitecustomize.py or PYTHONSTARTUP file:

import __builtin__, random
choices = range, xrange
for name in "xrange", "range":
    setattr(__builtin__, name, random.choice(choices))
del __builtin__, random, choices, name

Use that for a week at your site and see whether anybody notices.  Either
way, blame me <wink>.





More information about the Python-list mailing list