Saturday, 28 September 2013

why multiple assignments and single assignments behave differently in python

why multiple assignments and single assignments behave differently in python

I was working with queue in python when I had a error in code even while
the code looked very perfect to me but latter when I changed assignment
style all of sudden the code started working. The code looked some what
like this before.
x=y=Queue()
x.put("a")
x.put("b")
print y.get()
later i changed to this and it started working
x=Queue()
y=Queue()
x.put("a")
x.put("b")
print y.get(10)
why do both code work differently?

No comments:

Post a Comment