A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-September/091520.html below:

[Python-Dev] why different between staticmethod and classmethod on non-callable object?

[Python-Dev] why different between staticmethod and classmethod on non-callable object? [Python-Dev] why different between staticmethod and classmethod on non-callable object?xiaobing jiang s7v7nislands at gmail.com
Tue Sep 1 05:47:44 CEST 2009
hi all:
In the svn thunk tree, I find in file Object/funcobject.c, the two
functions: sm_init and cm_init have a little different. the cm_init
function will check the object is really callable, but the sm_init
don't.
the code like this:
    if (!PyCallable_Check(callable)) {
        PyErr_Format(PyExc_TypeError, "'%s' object is not callable",
             callable->ob_type->tp_name);
        return -1;
    }

so when use staticmethod and classmethod on a class variable, there
are two different behavior.

class Test(object):
    name = "s7v7nislands"

name = classmethod(Test.name)   # will raise error.
name = staticmethod(Test.name)  #  will not raise error.


My idea is: here, the two functions (or maybe classes) should have the
same behavior).
so is this a bug or something I missing ?

thanks!

s7v7nislands
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4