Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63041
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'syntax': 0.04; 'assignment': 0.07; 'class,': 0.07; 'nicely': 0.07; 'consistency': 0.09; 'inserted': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rejected': 0.09; 'python': 0.11; 'jan': 0.12; 'assignments': 0.16; 'c/c++': 0.16; 'ought': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'suggestion.': 0.16; 'target"': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'appears': 0.22; 'header:User-Agent:1': 0.23; 'source': 0.25; 'possibly': 0.26; 'suggested': 0.26; 'post': 0.26; 'least': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'testing': 0.29; 'character': 0.29; 'end,': 0.31; 'equality': 0.31; 'gary': 0.31; 'occurs': 0.31; 'post.': 0.31; 'workaround': 0.31; 'another': 0.32; 'quite': 0.32; 'style': 0.33; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'whilst': 0.36; 'example,': 0.37; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'easy': 0.60; 'liked': 0.60; 'john': 0.61; 'received:173': 0.61; 'further': 0.61; 'different': 0.65; 'here': 0.66; 'between': 0.67; 'advantages': 0.68; 'apart': 0.72; "'with'": 0.84; 'avoids': 0.84; 'received:fios.verizon.net': 0.84; 'sorry.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Ifs and assignments |
| Date | Fri, 03 Jan 2014 03:53:53 -0500 |
| References | <52C59FF6.5000607@allsup.co> <52C5BD90.9020609@islandtraining.com> <52C5DDA6.5090207@allsup.co> <52C60AF6.8060004@islandtraining.com> <la5390$9s8$2@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-254-207.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <la5390$9s8$2@ger.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4840.1388739251.18130.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388739253 news.xs4all.nl 2858 [2001:888:2000:d::a6]:33438 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63041 |
Show key headers only | View raw
On 1/2/2014 8:20 PM, Mark Lawrence wrote:
> On 03/01/2014 00:57, Gary Herron wrote:
>> On 01/02/2014 01:44 PM, John Allsup wrote:
>>> The point of my original post was that, whilst C's
>>> if( x = 2 ) { do something }
>>> and
>>> if( x == 2 ) { do something }
>>> are easy to confuse, and a source of bugs, having a construct like
>>> follows:
>>>
>>> if x == 2:
>>> do something # what happens at present
>>> if testFunc() as x:
>>> do something with x
>>>
>>> using the 'as' syntax that appears with 'with' and 'except', would allow
>>> for the advantages of C style assignments in conditionals but without
>>> the easy confusion, since here the syntax is significantly different
>>> between assignment and equality testing (rather than a character apart
>>> as happens with C).
>>>
>>> This occurs further down in my original post (past the point where you
>>> inserted your reply).
>>>
>>> Another post suggested a workaround by defining a 'pocket' class, for
>>> which I am grateful.
>>>
>>> John
>>
>> Sorry. I shot off my answer before reading the whole post. That's
>> never a good idea.
>>
>>
>> After reading to the end, I rather like your suggestion. It works well
>> in your example, , nicely avoids the C/C++ trap, and has some
>> consistency with other parts of Python.
>>
>> Gary Herron
>>
>>
>
> I liked the look of this as well. It ought to go to python ideas, or
> has it been suggested there in the past?
Yes, and rejected (I am quite sure). Consistency would 'demand' at least
"while expr as target" and possibly "for i in iterable_expr as target".
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Ifs and assignments Terry Reedy <tjreedy@udel.edu> - 2014-01-03 03:53 -0500
csiph-web