Clear all class variables between instances

Posted by ensnare on Stack Overflow See other posts from Stack Overflow or by ensnare
Published on 2010-03-24T21:30:07Z Indexed on 2010/03/24 21:33 UTC
Read the original article Hit count: 393

This is probably a stupid question, but what's the best way to clear class variables between instances?

I know I could reset each variable individually in the constructor; but is there a way to do this in bulk?

Or am I doing something totally wrong that requires a different approach? Thanks for helping ...

class User():
    def __init__(self):
        #RESET ALL CLASS VARIABLES

    def commit(self):
        #Commit variables to database

>>u = User()
>>u.name = 'Jason'
>>u.email = '[email protected]'
>>u.commit()

So that each time User is called the variables are fresh.

Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about pylons