Interpreting Left to right?

Chetan Harjani chetan.harjani at gmail.com
Fri Jun 24 04:41:10 EDT 2011


Now its all clear. Thanks
@ethan .. ur example is really scary.
I didnt understand ur example fully although.
See this is what i take it as:
x=x['huh']={}

>first python checks check that there are two = operators.
>so it evaluates the RHS(since for = it is RHS to LHS) experession of right
most (why is that?)
>now it assigns that experrsion({...}) to x the left most as u said first
RHS to LHS then LHS to RHS.
>then it assigns x to to x['huh'].
huh!!, ryt?
may be it doesnt make sense but i guess this is the only way to actually not
raise an error.

Where am I wrong?





On Fri, Jun 24, 2011 at 10:02 AM, Chetan Harjani
<chetan.harjani at gmail.com>wrote:

> x=y="some string"
> And we know that python interprets from left to right. so why it doesnt
> raise a name error here saying name 'y' is not defined?
>
> another example:
> (1,2) + 3,
> here, python raises a  TypeError "can only concatenate tuple(not int) to
> tuple" but we know (3,) is a tuple as seen by following:
> t=3,
> type(t)
> <type 'tuple'>
> Arent both of this contradicting?
>
> --
> Chetan H Harjani
>
>


-- 
Chetan H Harjani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110624/21b286ac/attachment-0001.html>


More information about the Python-list mailing list