Bruno Desthuilliers wrote:
I think you broke something somewhere. Assuming you're using Python 2.x
(>= 2.3 IIRC), my above code works.
ARGH! Forgot the "delayed staticmethod" line -- in effect I called
staticmethod twice:
@staticmethod
def print_internal_date(filename):
f =
mk a écrit :
Bruno Desthuilliers wrote:
class Foo4(object):
""" working solution 2 : use a lambda """
@staticmethod
def bar(baaz):
print baaz
tagada = {'bar': lambda x : Foo4.bar(x)}
def test(self, baaz):
self.tagada['bar'](baaz)
Huh? How does this one
Bruno Desthuilliers wrote:
class Foo4(object):
""" working solution 2 : use a lambda """
@staticmethod
def bar(baaz):
print baaz
tagada = {'bar': lambda x : Foo4.bar(x)}
def test(self, baaz):
self.tagada['bar'](baaz)
Huh? How does this one work? After al
mk a écrit :
Bruno Desthuilliers wrote:
(snip)
class Foo2(object):
""" naive solution : kinda work, BUT will fail
with the real code that has plain functions
in 'tagada'
"""
@staticmethod
def bar(baaz):
print baaz
tagada = {'bar': bar}
def test
Bruno Desthuilliers wrote:
I think I know where the problem is: what resides in tagdata is a
static method 'wrapper', not the function itself, according to:
Indeed. Sorry, I'm afraid I gave you bad advice wrt/ using a
staticmethod here - I should know better :( (well, OTHO staticmethods
are n
mk a écrit :
I'm trying to get print_internal_date become a static method AND to
refer to it in a class attribute 'tagdata' dict.
class PYFileInfo(FileInfo):
'python file properties'
@staticmethod
def print_internal_date(filename):
f = open(filename + 'c', "rb")
da
mk, 18.02.2010 12:12:
> I'm trying to get print_internal_date become a static method AND to
> refer to it in a class attribute 'tagdata' dict.
>
> class PYFileInfo(FileInfo):
> 'python file properties'
>
> @staticmethod
> def print_internal_date(filename):
> f = open(filename