This is driving me insane!

Duncan Smith buzzard at urubu.freeserve.co.uk
Thu Sep 26 20:47:02 EDT 2002


"Derek Basch" <dbasch at yahoo.com> wrote in message
news:mailman.1033084697.25598.python-list at python.org...
> Hello,
> I created a very simple class that totals some data
> but I am not getting the output from it that I would
> expect at all.
> Here is the class:
> http://www.geocities.com/dbasch/insane.txt
>
> I would expect to get:
> [0, 0]
> [0, 0]
> [[0, 0]]
>
> but I am getting:
> [0, 0]
> [0, 0]
> [[1, 1]]
>
> I dont understand how the 'grouptotals' list is
> getting the incremented values prior to the
> 'grouptotalcounter' function being called.

It isn't.  self.errorlog is a list containing self.grouptotals.  When you
increment self.grouptotals and return self.errorlog you will get [[1,1]].
Changing the appropriate line to 'self.errorlog.append(self.grouptotals[:])'
will append a copy of self.grouptotals and your function will then return
[[0,0]].

Duncan






More information about the Python-list mailing list