Hi all,
How can I call a static/class Python method from Perl correctly without
having to create an object first? The following simplified example
illustrates
the problem. In reality the MyClass resides in a Python module
along-with many other classes.
use Inline Python;
my $c = new MyClass('TEST');
print $c->aStaticMethod, "\n";
print $c->aClassMethod, "\n";
# How can I do that using a syntax
# similar to MyClass.aStaticMethod()
__END__
__Python__
class MyClass:
def __init__(self, name):
self.name = name
def aStaticMethod():
return 'This is a static method of MyClass.'
def aClassMethod(cls):
return 'This is a class method: %s' % repr(cls)
aStaticMethod = staticmethod(aStaticMethod)
aClassMethod = classmethod(aClassMethod)
Thanks,
- Subir