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
5
  • Aside from the fact that the grammar doesn't define it? Are you looking for a reason why Python doesn't support it? Commented Jan 30, 2019 at 23:38
  • Near duplicate: stackoverflow.com/q/39871227/1126841, which confirms that this is invalid syntax without providing a rationale. Commented Jan 30, 2019 at 23:40
  • 1
    Here's a thread from the python-ideas mailing list discussing the idea. Commented Jan 30, 2019 at 23:43
  • This doesn't provide anywhere near enough benefit to justify its addition. Commented Jan 30, 2019 at 23:45
  • (Plenty of syntax is possible. That doesn't mean it's worthwhile.) Commented Jan 30, 2019 at 23:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.