ookstore for the cookbook (O'reily's, right?). i thought it was too
cryptic but maybe time for met to revisit the book.
--
yosuke kimura
Center for Energy and Environmental Resources
The Univ. of Texas at Austin, USA
--
http://mail.python.org/mailman/listinfo/python-list
y and metaclass, but
instance doesn't disappear when I think it should disappear. I am also
wondering if it is easier to keeping {name:id(obj)} would be a better
solution.
Any other suggestions are very much appreciated as well.
--
yosuke kimura
Center for Energy and Environmental Resou
his to be somthing like
c = a + b
d = 1 / c
and each of a, b, c, d knows how to operates on each elements, and also
keep track of the sum.
I think i will settle for extending dict to have sum property and keep
track of it .
> You say you have code to check that the values are numeric; why
return self._sum
> # overload all other methods that mutate the dict
> # to keep _sum up to date
>>>> d = MyDict()
>>>> d.sum()
> 0
>>>> d['a']=5
>>>> d.sum()
> 5
>>>> d['b']=10
>>>> d['a']=8
>>>> d.sum()
> 18
>>>>
Thank you. I will go with subclassing method.
--
yosuke kimura
Center for Energy and Environmental Resources
The Univ. of Texas at Austin, USA
--
http://mail.python.org/mailman/listinfo/python-list
may I ask an advice of
if my intention was legitimate one or not?
My intention was to have a propery 'sum' in my object, and which has sum
of all the values() of the dict (i have code to make sure that the value
of dict are all numeric). I could just the propery being calculated
everytime the property got __getattr__. But I thought that it was
inefficient to calculate the same number over and over when the value is
already known. So I was thiking of calculating the number only when the
dict got modified.
I also experimented with the idea of subclassing dict itself to
calculate the sum. Is this what would be better solution?
Thank you again,
> --
> Arnaud
--
yosuke kimura
Center for Energy and Environmental Resources
The Univ. of Texas at Austin, USA
--
http://mail.python.org/mailman/listinfo/python-list
print "t.d['a'] = 1"
obj.d['a'] = 1
print
# I want the "changed" property to be True
print 'obj.changed = ', obj.changed
--
yosuke kimura
Center for Energy and Environmental Resources
The Univ. of Texas at Austin, USA
--
http://mail.python.org/mailman/listinfo/python-list