0

I have a Python class Shape, which can perform matching. I called the corresponding method match:

class Shape:
...
    def match(self, image):

and it is working, as far as I can tell. Is there a reason to avoid using match keyword as a method name and substitute it by a different word at the cost of semantic clarity, i.e. any situation where this class would not behave as expected?

Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
  • 4
    Do you mean because of [the `match` statement](https://docs.python.org/3/reference/compound_stmts.html#the-match-statement)? As it says there `match` is a _soft keyword_. Preventing attributes named `match` would break, amongst other things, [the standard library](https://docs.python.org/3/library/re.html#re.match); it can still be used as a variable or argument name too. – jonrsharpe Apr 25 '23 at 23:26
  • @jonrsharpe I didn't know the distinction between soft and "hard" keywords. – Paul Jurczak Apr 25 '23 at 23:29

0 Answers0