I have a class, and would like to change an object of it (similar to the pop method of lists), without adding an foo = foo.bar()
In simpler terms, i'd like to do foo.bar() instead of foo = foo.bar(). Is this possible in python?
Here's some code that i have, which hopefully furthers understanding:
class mystr(str):
    def pop(self, num):
        self = list(self)
        changed = self.pop(num)  # The particular character that was removed
        self = ''.join(self)  # The rest of the string
    
        # Somewhere in here i need to be able to change the actual variable that pop() was called on
        return changed  # Emulates python lists' way of returning the removed element.
my_var = mystr("Hello World!")
print(my_var.pop(4)  # Prints 'o', as you would expect
print(my_var)  # But this still prints 'Hello World!', instead of 'Hell World!'
# It isn't modified, which is what i want it to do