Re: accessing an object instance by only having one of its attribute values

2007-07-08 Thread mshiltonj
On Jul 8, 8:29 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Jul 8, 2:11 pm, mshiltonj <[EMAIL PROTECTED]> wrote: > I have some comments on the Pythonicity of your suggestions. Same > assumption, object attr is a unique key of some sort. How to create > the dic

Re: accessing an object instance by only having one of its attribute values

2007-07-08 Thread mshiltonj
On Jul 8, 2:18 pm, [EMAIL PROTECTED] wrote: > Hello all, > > Imaybe someone can help me with this question. > Is there a direct way of accessing an object instance, if all I know > is the value of one of its attributes? > The object is part of a list of objects, and I would like to pick the > objec

Re: In search of python idiom for accessing arbitrary fields at run time

2007-07-08 Thread mshiltonj
On Jul 8, 2:31 pm, "OKB (not okblacke)" <[EMAIL PROTECTED]> wrote: > mshiltonj wrote: > > In python, I'm doing something like this: > > > def three_fields(self, field1, field2, field3): > > for field in (field1, field2, field3): > >

In search of python idiom for accessing arbitrary fields at run time

2007-07-08 Thread mshiltonj
I'm trying to find the preferred python idiom for access arbitrary fields of objects at run time. For example, say I have an object the business code will do *something* with three arbitrary fields at a given time, but I don't know what the three fields are at run time. In perl, I'd do something