Variable as statement in python?
<p>I was reading some python code and come across this. Since I mostly write C and Java (And variable as statement doesn't even compile in these language) I'm not sure what it is about in python.</p>

<p>What does <code>self.current</code>, the "variable as statement", means here? Is it just some way to print the variable out, or this is a special grammar thing / practice in dealing with exceptions in python?</p>

<pre><code>class PriorityQueue():

    def __init__(self):
        self.queue = []
        self.current = 0   

    def next(self):
        if self.current &gt;=len(self.queue):
            self.current
            raise StopIteration

        out = self.queue[self.current]
        self.current += 1

        return out
</code></pre>

<p>I realized that this can be used for checking whether the attribute/method actually exist in the passed parameter. May be useful for input sanity check.</p>

<pre><code>def test(value):
    try:
        value.testAttr
    except AttributeError:
        print "No testAttr attribute found"
</code></pre>

python