0

For example, there already exist +, -... which can be overwritten using __add__ and __sub__ respectively. However, is it possible to write a new operator like . or x?

1
  • 2
    No. There are only specific operators that can be overwritten. Python doesn't let you add your own. You cannot change the grammar of the language. Commented Aug 19, 2022 at 6:03

1 Answer 1

1

No, you cannot, although there's some weird hackyness than can be done,

But if you want smt like:

1 x 2

You'll have to make a preprocessor

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.