Confused by Method(function) of a module and method ofaclass/instance

Fredrik Lundh fredrik at
Tue Mar 7 08:51:31 CET 2006

"Sullivan WxPyQtKinter" wrote:

> More confusing things came out to me:
> >>>str().lower()
> ''                                                  #well, this is
> understandable.
> >>>str.lower(str(),'A')
> 'a'
> How do you explain this result?

I get:

>>> str.lower(str(), 'A')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: lower() takes no arguments (1 given)

if you meant to write

>>> str.lower('A')

it's because "str" is the class that implements methods for the "str" type,
and, for an instance I of the class C:




are, in general, the same thing in Python


More information about the Python-list mailing list