Constructor not recognizing attribute member
<p>I have the following constructor for my <code>Dbconn</code> class:</p>

<pre><code>def __init__(self):
    self.host     = "localhost"
    self.database = "my_database"
    self.username = "username"
    self.password = "password"

    try:
        self.db = MySQLdb.connect(
            self.host,
            self.username,
            self.password,
            self.database
        )
        self.cursor = self.db.cursor()
    except:
        print "There was an error while connecting to the database"
        self.db.rollback()
</code></pre>

<p>however, when I execute the program, I get:</p>

<pre><code>  File "database.py", line 39, in __init__
    self.db.rollback()
AttributeError: Dbconn instance has no attribute 'db'
</code></pre>

<p>Any clues why I'm getting that?</p>
