Built-in functions and keyword arguments

Armando Serrano Lombillo arserlom at gmail.com
Mon Oct 29 09:52:04 EDT 2007


Why does Python give an error when I try to do this:

>>> len(object=[1,2])
Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    len(object=[1,2])
TypeError: len() takes no keyword arguments

but not when I use a "normal" function:

>>> def my_len(object):
	return len(object)

>>> my_len(object=[1,2])
2




More information about the Python-list mailing list