Automatically creating a list
<p>I am trying to automatically create the following list:</p>

<pre><code>[Slot('1A', '0', 0), Slot('2A', '0', 0),
 Slot('1B', '0', 0], Slot ('2B,'0', 0), ....]
</code></pre>

<p>By defining slot as:</p>

<pre><code>class Slot:
    def __init__(self, address , card, stat):
        self.address = address
        self.card = card
        self.stat = stat


board = []
for i in range(1, 13):
    for j in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']:
        board.append(Slot ((str(i)+j,'0', 0)))
print(board)
</code></pre>

<p>Using Python 3.5 in Windows. What is wrong? How I can do that? Thanks.</p>

<p>You have enclosed all arguments to <code>Slot</code> in a single parenthesis thereby passing a single argument to an <code>__init__</code> that expects three (and the <code>TypeError</code> raised hints to that). Remove the unnecessary set of parenthesis:</p>

<pre><code>board.append(Slot(str(i)+j,'0', 0))
</code></pre>

<p>and it works fine.</p>

<p>As an addendum, <code>print(board)</code> will return a quite unpleasant view of the objects, I'd suggest overloading <code>__str__</code> and <code>__repr__</code> to get a better view of the created objects: </p>

<pre><code>class Slot:
    def __init__(self, address , card, stat):
        self.address = address
        self.card = card
        self.stat = stat

    def __str__(self):
        return "Slot: ({0}, {1}, {2})".format(self.address, self.card, self.stat)

    def __repr__(self):
        return str(self)
</code></pre>

<p>Now <code>print(board)</code> prints:</p>

<pre><code>print(board)
[Slot: (1A, 0, 0), Slot: (1B, 0, 0),..., Slot: (12H, 0, 0), Slot: (12I, 0, 0)]
</code></pre>

python python-3.x