Class data being zapped by method



Hi,

I'll cut to the chase.

I have a class named Foo(). I create an instance of this class named
bar, and I set bar.data to a large list of tuples.

Within Foo() there is a method which operates on self.data. I need to
call this method after I set self.data from the "outside" (bar.data),
which isn't a problem. However, I have found through simple debugging
procedures that while bar.data exists fine before the said method is
called, self.data within the class method is EMPTY. In my class
constructor I do declare self.data to be an empty list ([]), but
shouldn't self.data contain the populated list?

Basically...

--------------------------------------------------------------------------
class Foo():
__init__(self):
self.data = []
a_count(self):
....
print self.data
....

bar = Foo()
bar.data = [(-74.0015, 1), (123.451, 18), ...]
print bar.data # Get what I expect
bar.a_count() # []
--------------------------------------------------------------------------

This is a *highly* simplified version of what I'm actually doing. If
more code is needed just ask.

Thanks in advance.

.



Relevant Pages

  • Re: Insert with response
    ... FooBar, there's no way and no need to put them in synch. ... column in the foo table to 250 calumns in the bar table. ... set statistics time off ...
    (microsoft.public.sqlserver.programming)
  • Re: Magic function
    ... processing objects created in root at depth 3 ... root obj2 at depth 3 ... processing objects created in foo at depth 2 ... processing objects created in bar at depth 0 ...
    (comp.lang.python)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... Unfortunately this is a side effect of using the os's directory structure to represent a python "package" structure. ...
    (comp.lang.python)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... A path below the package level is generally a good means to shoot ... to represent a python "package" structure. ...
    (comp.lang.python)
  • Re: how to deserialize variable element/node
    ... string bar; ... In the first deserialization case, bar = "sometimes a simple string is ... Your two XML fragments would have to be represented in an XML schema by ...
    (microsoft.public.dotnet.xml)