Finding the instance reference of an object

Astley Le Jasper Astley.lejasper at gmail.com
Thu Oct 16 19:25:05 CEST 2008


On 16 Oct, 18:53, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> Astley Le Jasper schrieb:
>
>
>
> > On 16 Oct, 16:52, Carsten Haese <carsten.ha... at gmail.com> wrote:
> >> Astley Le Jasper wrote:
> >>> Sorry for the numpty question ...
> >>> How do you find the reference name of an object?
> >>> So if i have this
> >>> bob = modulename.objectname()
> >>> how do i find that the name is 'bob'
> >> Why do you need to find that? You know that its name is 'bob'.
>
> >> --
> >> Carsten Haesehttp://informixdb.sourceforge.net
>
> > I'm creating mulitple instances, putting them in a list, iterating
> > through the list to send them to some functions where process them
> > with some instance specific parameters. Something along the lines of:
>
> > bob = someobject()
> > harry = someobject()
> > fred = someobject()
>
> > parameterdict = {'bob':(0,1,2),'harry':(3,4,5),'fred':(6,7,8)}
> > people_list = (bob, harry, fred)
>
> > for person in people_list:
> >   add_parameters(person)
>
> > def add_parameters(person)
> >   mytuple = parameterdict[??????instance.name????]
> >   person.x = mytuple[0]
> >   person.y = mytuple[1]
> >   person.z = mytuple[2]
>
> > ... alternatively there is probably a very much easier way of doing
> > it.
>
> Why not simply do
>
> bob = someobject(0, 1, 2)
>
> ?
>
> Diez

Because that was pseudo code to demonstrate what I was trying to
achieve. The parameters are more complicated than that.



More information about the Python-list mailing list