Title: Class methods

Is there any way to create a class method?  I can create a class variable like this:

class Foo:
  classVariable = None
  def __init__(self, classVariable):
    Foo.classVariable = classVariable

A = Foo('a')
B = Foo('b')

Print 'The class variable for A is "%s" and the class variable for B is "%s"'%(a.classVariable,b.classVariable)

When you run this, you see the following:

The class variable for A is "b" and the class variable for B is "b"

This is what I expect.  However, I wand to write a function that can be called on a class directly.  Lets say the name of the function is bar.  This function needs to be callable without an instance.  The class will be maintaining a queue, as a class variable, that all instances of that class will use to place data in.  When bar is called - perhaps by Foo.bar() - bar will operate on the all of the data provided by its instances.

Any ideas? 
 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to