Simulating call-by-reference
Dan Sommers
me at privacy.net
Thu Nov 17 15:45:04 EST 2005
On Thu, 17 Nov 2005 12:31:08 -0800,
aleax at mail.comcast.net (Alex Martelli) wrote:
> Dan Sommers <me at privacy.net> wrote:
> ...
>> Put the results into a dictionary (untested code follows!):
[ example code snipped ]
>> Now you can access the results as results['foo'], etc. Or look up
>> the Borg pattern in the ASPN cookbook and you can access the results
>> as results.foo, etc.
> I think you mean the Bunch idiom, rather than the Borg one (which has to
> do with having instances of the same class share state).
Oops. <sheepish grin>
You're right.
Sorry.
> Personally, I would rather pass myvar as well as the attribute names,
> and set them with setattr, as I see some others already suggested.
I lose track of things too easily that way. YMMV.
Regards,
Dan
--
Dan Sommers
<http://www.tombstonezero.net/dan/>
More information about the Python-list
mailing list