class unbound method and

cinsky at cinsky at
Tue Jan 9 07:39:55 CET 2007

Hi, I got confused when I learned the function

So far I learned, unless an instance is created, it is not possible to
call the class method. For example:

class Foo:
  def foo(self):
    pass  # error: unbound method foo().

What makes me confused is that datetime class? in datetime module
provides today() function that returns the datetime object.

>>> import datetime
datetime.datetime(2007, 1, 9, 15, 34, 35, 23537)

It looks like that datetime class provides today() method that can be
callable even if it is unbound method. Do I correct?

If it is possible to make that kind of function (looks like static
member function in C++), how can I make that?

Thanks in advance.

More information about the Python-list mailing list