Y
Hacker News
new
|
ask
|
show
|
jobs
by
maxerickson
4567 days ago
You can also pass in the method from the str type:
key=str.lower
It will be faster, but it will break on elements that aren't strings (which could be good or bad).
1 comments
koenigdavidmj
4567 days ago
Then you can use
key=operator.methodcaller("lower")
and handle any type.
link