Emmanuel Surleau:
> On an unrelated note, it would be *really* nice to have a length property on
> strings. Even Java has that!

Once you have written a good amount of Python code you can understand
that a len() function, that calls the __len__ method of objects, is
better. It allows you to write:
sorted(seq, key=len)

Instead, if you have a len attribute you need:
sorted(seq, key=attrgetter("len"))
Or even:
sorted(seq, key=lambda x: x.len)

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to