Hacker News new | past | comments | ask | show | jobs | submit login

I tend to see functions as merely a special-case of classes anyway. In a certain mindset, I consider this:

    def foo(...):
        ...
shorthand for this:

    class Foo(object):
        def __call__(self, ...):
            ...
    foo = Foo()
And so, if the situation warrants, I may expand some function to instead be a full class, take init arguments, etc. But commonly I don't. Even the case of a (not too complex) decorator I feels is handled nicer by closure than by instance variables.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: