Aug-15-2020, 08:50 PM
(This post was last modified: Aug-15-2020, 10:51 PM by deanhystad.)
Variables in Python are a reference to an object, not the storage for an object. You can write Python programs that don't use any variables at all.
Your recursive function calls do not need variables. Just we were only interested in the result of
Are you wondering what happens to all those Python objects that are created? A vast majority of them get tossed in the trash when no longer needed, their storage made available to be reused for new Python objects. The only objects that are not tossed in the trash are those referenced by a variable.
print(1 + 2)This is a valid program. It has a Python object that is the integer 1, and another that is the integer 2. It adds 1 and 2 together and we get another Python object for the result. There is no variable referencing the result, but there is still an object. When print is called it converts the Python object 3 to a string, yet another Python object, appends a linefeed, creating yet another Python object, and prints the string to stdout.
Your recursive function calls do not need variables. Just we were only interested in the result of
1 + 2
your function is only interested in the result of self.subsetsRecur(current, sset[1:]) +self.subsetsRecur(current + [sset[0]], sset[1:])
Are you wondering what happens to all those Python objects that are created? A vast majority of them get tossed in the trash when no longer needed, their storage made available to be reused for new Python objects. The only objects that are not tossed in the trash are those referenced by a variable.