pointing at who?

Tim Peters tim.one at home.com
Sat Feb 17 13:47:13 EST 2001

[Ben de Luca]
> hmm i am trying to find out how the assignmnet in this situation would
> occure, is talkingdata[1] the same as
> (talkingTo[CorrectNumber])[1] in this
> situation

I'm doing my best to break this at sentence boundaries, but you didn't make
it easy <wink>.  The answer is probably "yes".

> in essense i want to wait for the switch to flip? can i do this
> other wise i will have to use another message or starve
> talkingData=[sender,threading.Event(),''] #create working data


> data=[] #create final data

You never use this again, so unclear why it's here.

> self.talkingToLock.acquire() #one hand in the cookie jar at a time
> self.talkingTo.append(talkingData) #put in the cookies
> self.talkingToLock.release()#shut the lid

You didn't tell us anything about self.talkingTo.  Assuming it's a list.  If
so, list.append is atomic and you don't really need the acquire/release pair
around it.

> talkingData[1].wait() #wait for response

After list.append(x), and regardless of x,

    list[-1] is x

is true.  So, ya, for some value of i,

    self.talkingTo[i] is talkingData

is true, i.e. they're exactly the same object.

BTW, drop the fiddly list and create a little SharedData (whatever) class so
you can at least *name* these fields.  Meaningless little integers will come
back to bite you some day.

they-breed-in-the-dark-and-some-have-very-sharp-edges-ly y'rs  - tim

More information about the Python-list mailing list