Ben Finney wrote: > mosscliffe <[EMAIL PROTECTED]> writes: > >> I have tried the following, for a one dimensional list and it works, >> but I can not get my head around this lambda. How would this be >> written, without the lamda ? >> >> mylist = ['Fred','bill','PAUL','albert'] >> >> mylist.sort(key=lambda el: el.lower()) > > Here's a hint: > > >>> "FoO".lower() > 'foo' > >>> str.lower("FoO") > 'foo'
But be aware that you lose both the ability to override and duck-typing: >>> print r # derived from str Upper East Side >>> print s # unicode München >>> r.lower(), str.lower(r) ('Lower East Side', 'upper east side') >>> s.lower(), str.lower(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: descriptor 'lower' requires a 'str' object but received a 'unicode' Peter -- http://mail.python.org/mailman/listinfo/python-list