Is destructor concept available in Python?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psbasha
    Contributor
    • Feb 2007
    • 440

    #1

    Is destructor concept available in Python?

    Hi,

    Is there any destructor concept available in Python?.

    I have some data members of a class as list and dictionary.I would like to clear the data after ussage of it.

    If I have destructor,it will be easy to delete that variables in that method.

    Thanks in advance
    - PSB
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by psbasha
    Hi,

    Is there any destructor concept available in Python?.

    I have some data members of a class as list and dictionary.I would like to clear the data after ussage of it.

    If I have destructor,it will be easy to delete that variables in that method.

    Thanks in advance
    - PSB
    You can
    Code:
    del anyObject
    but make sure that you don't have any references to it that are hanging around. del(ete) will remove the name from the name space and mark the object for GC.

    Comment

    Working...