Why doesn't this method have access to its "self" argument?

Chris Angelico rosuav at gmail.com
Thu Nov 19 12:34:29 EST 2015


On Fri, Nov 20, 2015 at 3:13 AM, Robert Latest via Python-list
<python-list at python.org> wrote:
> rl at dc:~/c/cwsf/python_module$ python test.py
>
> Minimal example files:
>
> ========================== test.py ===================================
>
> import cmethod
>
> class Test():
>
> # add methods to the class "after the fact"
> Test.py_method = py_method
> Test.c_method = cmethod.c_method

Are you using Python 2 here? If so, you're using an old-style class,
which has specific consequences that I can never remember. Does the
situation change if you slap 'object' between those parentheses? Or if
you use Python 3?

ChrisA



More information about the Python-list mailing list