What is the meaning of static and class methods ?

fowlertrainer at anonym.hu fowlertrainer at anonym.hu
Mon Jun 28 03:21:27 EDT 2004


Hi !

I read the MetaClasses / Unifying Howto in python.org, but I cannot 
understand many things.

I use Delphi - I use many classes in it, and I know the Java class-es too.

In Delphi the class method is a method of class that callable without 
class creation.
In Delphi the object creation is used class method named Create.

Button:=TButton.Create(Owner);

The Create is working on class, not on created object, and it is create, 
and return the created object.
This is the only way to create objects.

But I don't understand, why we need class method-s in python. If I want 
to create an object, that is don't need to I execute this object's 
Create method.
Some other possible meaning is to create some class methods, that 
creates object with preinitialized state. Example: an ftp object with 
opened, and setted state.
But we can do that with simple functions too.

Another question is that what is the meaning of static methods ?
In Delphi the not overrided methods of class are static, but you cannot 
use the Self parameter in that methods.
In Java, the without static methods the JVM cannot run your main class, 
so it is needed to execute your program.

But in py I don't understand the meaning of that methods. In the 
examples I see that we cannot use self parameter in  static method - it 
is correct - but everything is seems to be that this is only a method 
with "special sign" that make the static method the piece of an object.

So:
I want to anyone please send an example of class/static methods that 
HAVE MEANING.
A real example, to I understand, why we need that methods in python.

Thanx for it:
 FT








More information about the Python-list mailing list