How to not put self. when initalizing every attribute in a Python class?
<p>Greetings.<br />
I searched for a long time, and found many related questions with no answer for me. Despite mine seems to be a simple beginner doubt.</p>

<p>We have a (I guess) typical class definition:</p>

<pre><code>class Town:
    def __init__(self, Name, Ruler = "Spanish Inquisition"):
        self.Name = Name
        self.Population = 0
        self.LocationX = 0
        self.LocationY = 0
        self.Religion = "Jedi"
        self.Ruler = Ruler
        self.Products = ["Redstone", "Azaleas"]
</code></pre>

<p>You get the idea. A lot of attributes. I need all of them.</p>

<p>The question is: **Is there a shortcut to save all those "self."?** Am I being too lazy? I hoped for something like:</p>

<pre><code>with self:
    Name = Name
    Population = 0
    ...
</code></pre>

<p>which of course I know does not work (this is not the use of "with", and arguments are in a wrong namespace. ... I got it right?).</p>

<p>I guess there are a lot of alternatives to achieve the same result, but I'm really curious about the power of Python classes, and I think other people asked about this with no success.</p>

<p>(A related question: <a href="http://stackoverflow.com/questions/1118006/most-pythonic-way-of-organising-class-attributes-constructor-arguments-and-su">Most &quot;pythonic&quot; way of organising class attributes, constructor arguments and subclass constructor defaults?</a> )</p>
