kinto-d kinto-d - 3 months ago 39
Python Question

How to recreate / reinstantiate an object in python 2.7

I am looking for a way to recreate / reinstantiate an object in python, because I want the object to have a default attribute in each loop.

for case in all_case:

# i want in each loop it's create a new object / reinstantiate it
pda = PushDownAutomata()
print pda.evaluate(case, debug=False)

# already add "del pda" but it's not working

How can I achieve it?


Note that class attributes are not the same as instance attributes. for example:

class A(object):

    a = None # this is a class attribute

    def __init__(self, b):
        self.b = b # b is an instance attribute