0

Example:

a = 5
b = a
del b # but I want to delete the memory of a using b's pointer.

So if this worked proper "a" would then return nothing. Because it would not longer exist.

Is there a b.object = None solution or something? Or is this type of pointer behavior not possible?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
maximusg
  • 143
  • 1
  • 7
  • 7
    `del b` impacts the *identifier*, not the *value*. Python doesn't use pointers; I'd recommend reading https://nedbatchelder.com/text/names1.html. – jonrsharpe Feb 26 '19 at 21:21
  • 1
    Python is a garbage collected language. What is your actual intent in doing this? – MrName Feb 26 '19 at 22:30
  • Possible duplicate of [Delete an object and all references to it in Python?](https://stackoverflow.com/questions/10068576/delete-an-object-and-all-references-to-it-in-python) – smci Feb 27 '19 at 02:15
  • Related/duplicate: [Delete an object and all references to it in Python?](https://stackoverflow.com/questions/10068576/delete-an-object-and-all-references-to-it-in-python), [Pointers in Python?](https://stackoverflow.com/questions/3106689/pointers-in-python). [How to delete every reference of an object in Python?](https://stackoverflow.com/questions/3013304/how-to-delete-every-reference-of-an-object-in-python) – smci Feb 27 '19 at 02:20

1 Answers1

0

del b impacts the identifier, not the value. Python doesn't use pointers; I'd recommend reading nedbatchelder.com/text/names1.html.


This was originally a comment by jonrsharpe.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65