[Python-3000] The case for unbound methods?

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 10 22:49:14 CET 2008


Anthony Tolle wrote:
> I'm wrapping an instance of  <type 'staticmethod'>
> I'm wrapping an instance of  <type 'classmethod'>
> I'm wrapping an instance of  <type 'function'>

Hmmm, so what you're really worried about is that
people will be able to create static methods without
using staticmethod().

I think the solution to this has already been
mentioned. If you're wrapping a method in something
that inserts an extra argument at the beginning,
then you write it as

   @somewrapper
   def meth(extra_arg, self, arg1, arg2, ...)
     ...

Simple, explicit, non-magical, no introspection
required.

-- 
Greg


More information about the Python-3000 mailing list