title: Where is the recommended way to put member variables when designing classes in python?
body: <p>I am trying to get familiar with classes in python. In C++ the structure of a class seems straightforward to me, regarding the member variables. You just declare them at the beginning of the class scope or at the end (as public or private, as desired) and work with them as you need.</p>
  
  <p>How is this handled in python?</p>
  
  <p>Right now I tend to write the class and declare the variable where needed:</p>
  
  <pre><code>class Foo():
      standard = "standard"
      def __init__(self, arg_1, arg_2):
          self.first = arg_1
          self.second = self.do_something(arg_2)
  
      def do_something(param):
          second = # do something with self.standard and param and store it.
          return second 
  
      def do_another_thing():
          self.third = # do another thing.
  </code></pre>
  
  <p>I know, that a class can be defined too without member variables and they can be added dynamically.</p>
  
  <pre><code>class Foo():
      pass
  
  foo = Foo()
  foo.a = "a"
  # etc.
  </code></pre>
  
  <p>Throwing all of this together it confuses me, since the code becomes harder to read.</p>
  
  <p>So my question is, <strong>what is the recommended way to design a class, regarding member variables in python?</strong></p>
  
  <hr>
  
  <h2>Edit:</h2>
  
  <p>The way I asked was misleading. Sorry about that! The answers helped me to understand other things, though. ;-)</p>
  
  <p>I'll rephrase: I am not asking for how to solve my confusion regarding <strong>variables defined inside the class</strong> and <strong>variables added dynamically</strong> while coding.</p>
  
  <p>What I wanted to solve was my confusion about the design of a python class, regarding member variables. I mean, <strong>where to put them the best</strong>, to allow a potential reader of the code to see everything <strong>without having to search for them</strong>. That's why I mentioned classes in C++. You have one place for all member variables and if you want to know which data is stored in the class you look at the beginning or the end of a class, and you get all the information you need.</p>
  
  <p>In the example I wrote above, you see, <code>standard</code> is above <code>__init__(self, ...)</code>, <code>first</code> and <code>second</code> are inside of <code>__init(self,...)</code> and <code>third</code> is inside <code>do_something()</code>, which if the class is big could be below all other methods. So you would have to search for it <em>line by line</em>, or never realise it existed.</p>
  
  <p>I hope my question is better proposed now. :-)</p>