Adding a field to a 'foreign' object from the outside
- From: atleta <atleta.hu@xxxxxxxxx>
- Date: Thu, 22 Jan 2009 19:19:26 -0800 (PST)
Hi,
I'm working with a callback API (a DBus one) and I'd need to store
some state between the calls somewhere. I know that it's possible to
extend an object with fields after creation, so I could just store my
data in the session object that is passed in with every callback.
However it stinks from OO perspective, at least to me. The other
option, something that I'd do in java for example, would be to set up
a mapping (a dict) using the session object as a key. Which one is the
'pythonic' way? Do you use the first method (modifying an object that
you don't even control the source of) or do you write a bit more code
and go with the second one?
Thanks,
Laszlo
.
- Follow-Ups:
- Re: Adding a field to a 'foreign' object from the outside
- From: Steve Holden
- Re: Adding a field to a 'foreign' object from the outside
- From: Bruno Desthuilliers
- Re: Adding a field to a 'foreign' object from the outside
- From: Diez B. Roggisch
- Re: Adding a field to a 'foreign' object from the outside
- From: James Mills
- Re: Adding a field to a 'foreign' object from the outside
- Prev by Date: Re: Python 2.4 vs 2.5 - Unicode error
- Next by Date: Re: What is intvar?
- Previous by thread: what gives with "'import *' not allowed with 'from .'"?
- Next by thread: Re: Adding a field to a 'foreign' object from the outside
- Index(es):
Relevant Pages
|
Loading