0

Is there any reason why this syntax wouldn't be possible?

def myclass.method(self):
    pass

Instead, python currently uses assignment, such as:

def f(self):
    pass
myclass.method = f
benjimin
  • 4,043
  • 29
  • 48
  • Aside from the fact that the grammar doesn't define it? Are you looking for a reason *why* Python doesn't support it? – chepner Jan 30 '19 at 23:38
  • Near duplicate: https://stackoverflow.com/q/39871227/1126841, which confirms that this is invalid syntax without providing a rationale. – chepner Jan 30 '19 at 23:40
  • 1
    Here's a [thread](https://groups.google.com/forum/#!topic/python-ideas/8rxVLGryXrg) from the python-ideas mailing list discussing the idea. – chepner Jan 30 '19 at 23:43
  • This doesn't provide anywhere near enough benefit to justify its addition. – user2357112 Jan 30 '19 at 23:45
  • (Plenty of syntax is *possible*. That doesn't mean it's *worthwhile*.) – user2357112 Jan 30 '19 at 23:46

0 Answers0