Returning an lvalue from a function in python
<p>[Sorry, I'm new in Python. Although it seems to be a very basic question, I did my share of due diligence before asking this audience, trying to avoid really stupid questions].</p>

<p>I'm trying to figure out the correct idiom for returning an l-value from a function. Assume I've a container of 64 objects, and I want to be able to return a reference to these objects.</p>

<pre><code>class ChessBoard:
    def __init__(self):
        self.squares = [None for x in range(64)]

    square( row, col ):
        return self.squares(row*8+col)    &lt;---- I'd like this to be l-value
</code></pre>

<p>Then, from outside the class I want to:</p>

<pre><code>board = ChessBoard()
board.square(0,0) = Piece( Shapes.ROOK, Colors.White )    &lt;-- I'm getting an error here
board.square(0,1) = Piece( Shapes.BISHOP, Colors.White )
... etc.
</code></pre>

<p>So, I would like the function 'at' to return a lvalue (Something like a reference in C++), but I can't find anything resembling a reference or a pointer in the language. If I stored a <strong>list</strong> in each square containing one Piece, it is possible I could do something like: board.square(0,0)[0] = Piece - but it seems crazy (or maybe not - as I said, I'm new to the language).</p>

<p>How would you approach this data structure? </p>
