TypeError: no arguments expected
Steve Holden
steve at holdenweb.com
Mon Dec 12 05:17:24 EST 2005
Dennis Lee Bieber wrote:
> On Sun, 11 Dec 2005 22:00:55 -0500, shawn a <boris317 at gmail.com>
> declaimed the following in comp.lang.python:
>
>
>>I havet these 2 files in the same dir. This is code im writing to learn pythong
>>mkoneurl.py:
>>#! /usr/bin/env python
>>
>>import make_ou_class
>>
>>run = make_ou_class.makeoneurl()
>
>
> Okay, you've just defined a "run" object that contains an instance
> of "makeoneurl"... What do you expect it to do?
>
Let's get the terminology right: sloppy terminology leads to sloppy
thinking. The statement binds the name "run" to a newly-created
"make_one_url" instance. Remember, "run" isn't an object, it's a
reference to an object like all Python names.
>
>>====================================
>>make_ou_class.py:
>>
>
> Well, first off... You need to /supply/ a placeholder for "self".
> ALL methods of a class receive the instance as the first argument. So...
>
Again you need to be a little careful here, since we now have class
methods and static methods to cloud the picture. So it would be more
accurate to say that "instance methods are all automatically called with
a reference to the instance as the first argument; it is conventional to
use the name 'self' to refer to the instance".
>
[...]
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
More information about the Python-list
mailing list