Static class methods
Greg Ewing
greg at cosc.canterbury.ac.nz
Wed Mar 7 20:50:12 EST 2001
> Alex Shindich wrote:
>
> This seems weird, since the level
> above the class-- the modules, can have functions. So can the level
> below-- the instance methods. But the classes cannot.
The class scope is already special with respect to
nested scopes anyway, since it doesn't count as a
scope when you're looking out from inside a method.
So even if there were class methods, you wouldn't
be able to call them from within a method without
qualification of some sort.
However, class scopes *do* behave like other scopes
in that the code in the body of the following function:
def g():
def f():
print "foo"
f()
works just the same way when *executed* in a class
scope:
class C:
def f():
print "foo"
f()
Try it and you'll see!
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list