title: Python: define object variable without initialization
body: <p>I am trying to rewrite my code from <em>one big function</em> to oop.</p>
  
  <p>If I have this, it crash on <code>session.add(a1) # Unresolved reference</code>:</p>
  
  <pre><code>from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy import *
  from sqlalchemy.orm import *
  
  Base = declarative_base()
  
  class Address(Base):
      __tablename__ = 'address'
      id = Column(Integer, primary_key=True)
      street = Column(String, nullable=False)
      city = Column(String, nullable=False)
      user = relationship('User', back_populates="address")
  
  class Main():
      def __init__(self):
          engine = create_engine('mysql://test:test@localhost:3306/test', echo=False)
          Session = sessionmaker(bind=engine)
          session = Session()
  
      def insert(self):
          #   INSERT
          a1 = Address()
          a1.street = "Str 123"
          a1.city = "City WTF"
  
          session.add(a1) # Unresolved reference
          session.commit()
  
  if __name__ == '__main__':
      Main().run()
  </code></pre>
  
  <p>I understand it. <code>session</code> is local object in constructor (<code>__init__</code>).</p>
  
  <p>But how can I put object "directly to class"?
  In Java I do something like:</p>
  
  <pre><code>public class Main {
      Engine engine;
      Session session;
      public Main() {}
          engine = create_engine('mysql://test:test@localhost:3306/test', echo=False)
          session = sessionmaker(bind=engine)
      }
      private insert() {
          //...
          session.commit();
      }
  }
  </code></pre>
  
  <p>How can I do it in python? <em>Sorry for stupid question, I am python newbie.</em></p>
  
  <p>--------------------- EDIT:</p>
  
  <pre><code>class Main():
      engine = None # What I write here? How declare uninitialized object?
      session = None # What I write here?
      def __init__(self):
          engine = create_engine('mysql://test:test@localhost:3306/test', echo=False)
          Session = sessionmaker(bind=engine)
          session = Session()
  
      def insert(self):
          #   INSERT
          a1 = Address()
          a1.street = "Str 123"
          a1.city = "City WTF"
          self.session.add(a1) # Is possible to call session without "self"?
          self.session.commit()
  </code></pre>