"Gregory Guthrie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > - why is len() not a member function of strings? Instead one says > len(w).
Consider >>> map(len, ('abc', (1,2,3), [1,2], {1:2})) [3, 3, 2, 1] Now try to rewrite this using methods (member functions). > - Why doesn't sort() return a value? Because it is an in-place mutation method and Guido decided that such methods should return None rather that the mutated object to lessen bugs. It is a tradeoff that has been debated ever since ;-) > For example: to acculumate words in a dictionary - > dict[key] += [word] This expands to dict[key] = dict[key] + [word]. When the latter is valid (when dict[key] exists and is a list), then the former works fine also. >>> k='a' >>> d = {k:[]} >>> d[k]+=['b'] >>> d {'a': ['b']} I presume the new-in-2.5 default dicts will do the same, and also work when the key does not exist and the default is a list. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list