Reputation: 1154
If I get the id of an object, how can I delete an object by it's id ?
Upvotes: 0
Views: 5323
Reputation: 10353
The id refers to a memory address. You "can't" delete (or free) a memory address, only its references, with the del statement
Upvotes: 0
Reputation:
This is not a good idea. Try using the weakref module, which allows you to create weak references (analogous to symbolic links) to objects.
Upvotes: 2
Reputation: 2104
You can delete objects by calling del() on them. But AFAIK id won't help in that.
Upvotes: -2
Reputation: 42168
AFAIK objects are deleted by garbage collector in python. You can't force a delete yourself.
Upvotes: 1