Problem with the sort() function
Steven Bethard
steven.bethard at gmail.com
Tue Feb 22 14:45:18 EST 2005
Scott David Daniels wrote:
> or even (if you can't be bothered to look up when features happened):
>
> try:
> test = enumerate
> except NameError:
> def enumerate(iterable):
> ...
> try:
> test = sorted
> except NameError:
> def sorted(iterable, cmp=None, key=None, reverse=False):
> ...
Ridiculously minor nit, but there's no reason to assign to test:
try:
enumerate
except NameError:
def enumerate(iterable):
...
try:
sorted
except NameError:
def sorted(iterable, cmp=None, key=None, reverse=False):
...
Just evaluating the expression 'enumerate' or 'sorted' should raise the
NameError if they don't exist.
STeVe
More information about the Python-list
mailing list