I have a Python set consisting of several values, and I want to use a method chain as follows:
>>> f = {1, 2, 3} >>> g = f.copy().discard(3) >>> g >>>
but g becomes empty. However, it works without chaining:
>>> g = f.copy() >>> g {1, 2, 3} >>> g.discard(3) >>> g {1, 2}
Can someone explain this behavior to me?
source share