Decorators: an outsider's perspective

Paul Morrow pm_mon at yahoo.com
Sat Aug 14 15:35:48 CEST 2004


Chas Emerick wrote:

[...snip...]
> 
> The first time I saw this, I almost fell out of my chair:
> 
> def blah (args):
> ....[insert 50/100/200 lines here]
> blah = staticmethod(blah)
> 

me too.

[...snip...]
> 
> So, when I see:
> 
> @staticmethod
> def blah (args):
> ....[insert 100 lines]
> 
> I say, YES!
[...snip...]

I say, NO!  And I wonder why we feel a need to explicitly (and 
superflously) 'declare' something that is already clearly evident in the 
code (when recommended coding practices are followed).

class Foo:
    def blah(a, b):         # this is clearly a static method
       pass

    def blah(self, a, b):   # this is clearly an instance method
       pass

    def blah(klass, a, b):  # this is clearly a class method
       pass

Python was built (successfully) on the assumption that obvious 
interpretations of the code obviate the need for declarations.  Why 
wouldn't we continue with that mindset?

Paul




More information about the Python-list mailing list