I am trying to come up with a succinct example for garbage collection of an object that no variable name holds a reference to, however this code doesn't seem to work. I would like to understand why to better understand the inner-workings of Python. It seems to have exposed something I misunderstood.
some_name = [['some_nested_lst_object_with_an_str_object']]
id(some_name)
'''
you don't normally need to do this.
This is done for the reference example.
Accessing garbage collector:
'''
import gc
print(gc.collect())
'''
If I assign something new to ''*some_name*'',
the reference to the previous object will be lost:
'''
some_name
print(gc.collect())
some_name = [[['something_new']]]
some_name
print(gc.collect())