On Sun, Sep 13, 2020 at 12:32:54AM -0400, Random832 wrote:
> This isn't what I was suggesting - I meant something like this:
> class instancemethod:
> def __init__(self, wrapped):
> self.wrapped = wrapped
> def __get__(self, obj, objtype):
> if obj is None: return self.wrapped
> else: return MethodType(self.wrapped, obj)
> this wouldn't be useful for functions, but would give other callables
> the same functionality as functions, automatically creating the bound
> method object, e.g.:
> class D:
> def __init__(self, obj, *args): ...
> class C:
> foo = instancemethod(D)
You want a method which does absolutely nothing at all but delegate to a
class constructor or callable object (but not a function), with no
docstring and no pre-processing of arguments or post-processing of the
Seems like an awfully small niche for this to be in the stdlib.
But having said that, I might have a use for that too. Except... I would
need a docstring. And pre- and post-processing. Hmmm.
Seems to me that this might be useful in theory, but in practice we
might never use it, preferring this instead:
def foo(self, *args):
return D(self, *args)
with appropriate pre- and post-processing as needed.
Interesting suggestion though, I may have to play around with it.
Python-ideas mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com
Message archived at https://firstname.lastname@example.org/message/QKAA54IV2WDEEWN354PK3JPSPIAMRGD2/
Code of Conduct: http://python.org/psf/codeofconduct/