PEP 542 proposes a shortcut notation when defining functions that would be added to a class. A discussion of this idea can be found here. Personally, I am not too fond of the idea ... but it's a good test case to see if I my nonstandard module, which I have mentioned before on this blog, could allow the proposed syntax to be used right now.
$$ type pep542_testfile.py
from __nonstandard__ import pep542 def test_pep542(): class MyClass: pass def MyClass.square(self, x): return x**2 a = MyClass() def a.out(): return 42 assert a.out() == 42 assert a.square(3) == 9
$$ python test_pep542.py Successfully tested function test_pep542
The answer seems to be yes ...