0

Suppose I want to add a method to one of python's main objects, like a normalize method to the tuple. To be specific, I want all tuples I declare in my file to have this method, like this:

foo = (3,4,5)

print(foo.normalize())

Is there any way I can do this for just the file I'm working in, like re-define the tuple class or something?

Xachaeus
  • 26
  • 4
  • Why not just make a function that normalizes any iterable? You could of course create a subclass that inherits from tuple. https://jfine-python-classes.readthedocs.io/en/latest/subclass-tuple.html –  Jul 06 '21 at 04:05

0 Answers0