On Class namespaces, calling methods

vsoler vicente.soler at gmail.com
Sat Apr 10 11:16:23 EDT 2010


On Apr 10, 4:46 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> vsoler <vicente.so... at gmail.com> wrote:
> > I get the following error message:
>
> >      TypeError: m() takes no arguments (1 given)
>
> > Since I have not created any instances of Uno, there is no self
> > object, and I do not understand what object is supplied to the
> > function call.
>
> > Could anybody explain what argument is being supplied to the method?
> > Is ther any workaround to call the m function?
>
> Which version of Python are you using? Python 2.6 gives:
>
> TypeError: unbound method m() must be called with Uno instance as first
> argument (got nothing instead)
>
> whereas Python 3.1 gives:
>
> >>> Uno.m()
>
> mouse
>
> (assuming you change the print statement to work on Python 3.x)

Hello Duncan,

Your error message is correct if you use         class Uno(object):
However, the error message is different under    class Uno:

Regards



More information about the Python-list mailing list