Thoughts about Python
paul at prescod.net
Tue Feb 24 19:09:31 CET 2004
Terry Reedy wrote:
> Quiz: how would you rewrite map(len, ['abc', (1,2,3,4), [5,6]]) if len()
> were a method?
map(lambda x: x.len(), ['abc', (1,2,3,4), [5,6]])
[x.len() for x in ['abc', (1,2,3,4), [5,6]]]
>>classes start with an uppercase letter:
>>myList = List()
> This appears to be a convention or rule you learned from another language.
> Though some Python programmers follow it, tt is not part of Python.
It actually is a pretty good convention. There really is a pretty big
distinction between functions and types (isa, inheritance etc.) so it is
good to distinguish them. Also, many classes in the standard library use
upper-case classes. (e.g. UserList, Pickler, etc.)
More information about the Python-list