Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8348

Re: Interpreting Left to right?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'languages,': 0.03; 'operator': 0.05; 'python': 0.08; 'exceptions': 0.09; 'rule.': 0.09; 'exception': 0.12; 'wrote:': 0.15; 'doesnt': 0.16; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interprets': 0.16; 'parameters,': 0.16; 'pm,': 0.16; 'received:209.85.210.174': 0.19; 'received:mail-iy0-f174.google.com': 0.19; 'header:In-Reply-To:1': 0.22; 'saying': 0.26; 'raise': 0.28; 'fri,': 0.28; 'message- id:@mail.gmail.com': 0.28; 'right.': 0.28; '24,': 0.29; 'subject:?': 0.31; 'too': 0.32; 'error': 0.33; 'does': 0.33; 'actually': 0.33; 'there': 0.34; 'to:addr:python-list': 0.34; 'safely': 0.35; 'url:python': 0.36; 'associates': 0.37; 'received:google.com': 0.37; 'but': 0.37; 'several': 0.37; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'case,': 0.38; 'comments': 0.38; 'url:docs': 0.39; 'to:addr:python.org': 0.39; "there's": 0.39; 'received:209': 0.39; 'sense': 0.40; 'taking': 0.65; 'here': 0.66; 'believe': 0.66; 'jun': 0.67; 'url:reference': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=Fzu+XM6+LuC4GhsAx1W2En5Dsezc0nL0JSlJJJpPX0M=; b=PmtC6otWcE30yodlg2nxaQRH0Tfzn1AApOPKBvOp1LrMz2vB3EdkUgYnnuHlQ47pPY wqJsy2Knd4ITX6ErYiFO1QXtjDhFRKBjiMeMPZM8HAFmj18OslOyb+/zsmaozVzfLR9U WWyLIXJ25RZktbDGMX1KjRLreAJ42rTmCYykU=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=uWjhdMSOaV3dDWE2XI1omh0XeslykeEko02LU0ZqOHhyMt7UrLotjkereyKepW8XT9 hnpeXmmOF4QS6mNw2XenaLyrp4jVojYl6txpN6jbTmSL4EByagmnF48hcPrmhEwBZDmF ED2IXPdldcx8bcKO3Tz1BLBrKk8cTEyC8+lPs=
MIME-Version 1.0
In-Reply-To <BANLkTimcPAjQP4JJk=OAbrkLFfd2AtndwQ@mail.gmail.com>
References <BANLkTimcPAjQP4JJk=OAbrkLFfd2AtndwQ@mail.gmail.com>
Date Fri, 24 Jun 2011 14:59:54 +1000
Subject Re: Interpreting Left to right?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.351.1308891597.1164.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 82.94.164.166
X-Trace 1308891597 news.xs4all.nl 14131 [::ffff:82.94.164.166]:43647
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8348

Show key headers only | View raw


On Fri, Jun 24, 2011 at 2:32 PM, Chetan Harjani
<chetan.harjani@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?

In most languages, the answer is that the = operator associates right
to left, even though most other operators associate left to right.
(That's how C does it, for instance.) But in Python, I believe it's
actually one operator taking several parameters, because = is not an
expression.

In any case, you can safely treat = as an exception to the
left-to-right rule. There are other exceptions too - note the comments
in http://docs.python.org/reference/expressions.html#summary - there's
not many RTL operators in Python, only those that make sense that way.
:)

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Interpreting Left to right? Chris Angelico <rosuav@gmail.com> - 2011-06-24 14:59 +1000

csiph-web