Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Arithmetic operators

As you know there are arithmetic operators like + or -. Is there a way to create my own operator which can execute a specific task between two variables?

For example:

a, b = 2, 5
a '+' b == 7

What I would like to do:

a 'my own operator' b == some_specific_value

Answer*

Draft saved
Draft discarded
Cancel
2
  • 1
    Although complex numbers are already there: print((1+1j) + (1-1j)) prints (2+0j). Also "imaginary" has only one 'm'. Commented Dec 1, 2021 at 1:41
  • Sorry for the „m" abundance! Commented Dec 1, 2021 at 17:39

lang-py

AltStyle によって変換されたページ (->オリジナル) /