0

So I was wondering is it possible to make a new dunder method that has its own operator? Something like this:

class test:
  def __init__(self, name):
     self.name = name
     pass
  def __user__(self, times):
    return(self.name*times)

---------- 
Run
----------

Python 3.7.1 Shell

>>> a = test('stackoverflow')
>>> a -!? 1
'stackoverflow'
>>>

Thanks in Advance!

**EDIT: ** Thank you @user2357112-supports-Monica and @Mad-Physicist for explaining to me what I wanted to do is impossible (without recompiling Python that is...) and how to do my original example.

RhinoCodes
  • 71
  • 7

0 Answers0