3 ms·
In any case, this can be done now with a helper class used as a decorator. >>> class At: __slots__= 'fun', def __init__(self, fun): self.fun =
by tzot 6y ago
In any case, this can be done now with a helper class used as a decorator.
>>> class At:
__slots__= 'fun',
def __init__(self, fun):
self.fun = fun
def __matmul__(self, arg):
return self.fun(arg)
def __call__(self, *args, **kwargs):
return self.fun(*args, **kwargs)
>>> @At
def square(x):
return x*x
>>> square(2)
4
>>> square@2
4