Multiple distinct objects: Difference between revisions

m
(added python)
Line 33:
=={{header|Python}}==
The mistake is often written as:
<code python>[Foo()] * n # here Foo() can be any expression that returns ana new object</code>
which is incorrect since <code>Foo()</code> is only evaluated once. A common correct version is:
<code python>[Foo() for i in xrange(n)]</code>
Anonymous user