Python3: Using sorted(key=...)
Paul Rubin
http
Fri Aug 7 00:42:04 EDT 2009
Johannes Bauer <dfnsonfsduifb at gmx.de> writes:
> def myorder(x):
> if type(x[0]) == int:
> return x[0]
> else:
> return x[0][0]
I used to write code like that pretty regularly, but over time I found
that it's better to stay consistent and use the same container format
(in this case, tuples) for everything, rather than having special
cases for the singleton and non-singleton case.
More information about the Python-list
mailing list