full closures
Michael P. Soulier
msoulier at nortelnetworks.com_.nospam
Wed Feb 27 16:39:02 EST 2002
On Wed, 27 Feb 2002 20:37:15 GMT, Terry Reedy <tjreedy at home.com> wrote:
>
>>>> def prcnt(counter = [0]):
> ... print "The current count is %d" % counter[0]
> ... counter[0] = counter[0] + 1
> ...
>>>> prcnt()
> The current count is 0
>>>> prcnt()
> The current count is 1
But that doesn't work with multiple instances of prcnt. They all share the
same reference to the default list you created.
Mike
--
Michael P. Soulier, QX41, SKY Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort." -Harley Hahn, A Student's Guide to Unix
More information about the Python-list
mailing list