News for hackers. Stuff that matters.
Re:Understanding Python Decorators by andrewcooke on Sunday August 07, 2011 @06:43PM (#2858014)
one workaround is to make your decorators require keyword arguments (which often makes good sense from a documentation POV). you can then add a first keyword argument as gatekeeper, with default value None, and check whether it has been defined. if so, the decorator was used incorrectly.

you can see what i mean here - http://code.google.com/p/lepl/source/browse/src/lepl/matcher...

this doesn't fix the problem completely, of course, but it does mean that a user that types @foo instead of @foo() gets a helpful warning explaining exactly what they have done wrong.

There are no comments on this comment yet.