Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.043 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'else:': 0.03; 'operator': 0.03; 'subject:Python': 0.05; 'received:134': 0.05; 'assignment': 0.07; 'python.': 0.11; 'syntax': 0.13; 'received:ac.be': 0.16; 'true:': 0.16; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'cases.': 0.29; 'exists,': 0.29; 'indentation': 0.29; 'received:be': 0.30; 'generally': 0.32; 'though,': 0.32; 'except': 0.34; 'level': 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'wrong': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'share': 0.61; 'skip:n 10': 0.62; 'making': 0.62; 'special': 0.73; 'hey,': 0.75; 'introduce': 0.79; 'construct': 0.84; 'pardon': 0.84; 'schreef': 0.84; 'seriously,': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0GAFxy9lWGuA9G/2dsb2JhbABdhDsBJIMqwhACgXkBAQEBAQGFLwEBAwEjVQYLCxoCBRYLAgIJAwIBAgFFEwYCAogiCLV9j0mEJgEBCAIggSKFUYR9hRQXglKBQwEElVeMfoFMhyGOJYNsY4QDbwGKfAEBAQ Date: Mon, 14 Sep 2015 09:13:45 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python handles globals badly. References: <86fa425b-d660-45ba-b0f7-3beebdec8e14@googlegroups.com> <55EE9EEC.1060907@rece.vub.ac.be> <55EEDD37.5090602@gmx.com> <55f072aa$0$1669$c3e8da3$5496439d@news.astraweb.com> <55f1a8df$0$1660$c3e8da3$5496439d@news.astraweb.com> <1441902711.3168172.380049449.32E41922@webmail.messagingengine.com> <87pp1pqi93.fsf@elektro.pacujo.net> In-Reply-To: <87pp1pqi93.fsf@elektro.pacujo.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442214835 news.xs4all.nl 23794 [2001:888:2000:d::a6]:37808 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96551 Op 11-09-15 om 13:59 schreef Marko Rauhamaa: > Antoon Pardon : > >> I just don't get why people want to introduce special cases in python. >> Why allow such a construct only in while and if? Why not just allow >> it generally as an assignment expression? >> >> Why not allow: >> >> while (f(x) as fx) > 5: >> proces(fx) >> >> or >> >> if check(nextvalue() as new): >> treat(new) > Hey, I know, I know!... Let's allow: > > while (fx = f(x)) > 5: > process(fx) > > if check(new = nextvalue()): > treat(new) > > Seriously, though, I share your distaste of special cases, Antoon. Only > I don't like too much syntax (just look at Perl). This proposal would have as an effect less syntax. The 'as ...' syntax already exists, but as special cases. Making 'as ...' a general assignment operator would eliminated the special cases and collect them all in the expression syntax. So less syntax. > There's nothing wrong > in: > > while True: > fx = f(x) > if fx <= 5: > break > process(fx) There was also nothing wrong with: if b > c: a = 5 else: a = 2 > new = nextvalue() > if check(new): > treat(new) Except that it would need an extra indentation level if it was an elif. -- Antoon Pardon