Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'example:': 0.03; 'own.': 0.03; 'plenty': 0.03; 'operator': 0.05; 'does.': 0.07; 'myself,': 0.09; 'none.': 0.09; 'tends': 0.09; 'examples': 0.11; 'argument': 0.15; '"write': 0.16; 'expression.': 0.16; 'file"': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mistake.': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.22; 'frequent': 0.23; 'pm,': 0.24; 'aug': 0.24; 'statement': 0.25; '(in': 0.26; "i'm": 0.27; 'function': 0.27; '(the': 0.28; 'lists': 0.28; 'message-id:@mail.gmail.com': 0.29; 'mainly': 0.29; 'print': 0.29; 'conditional': 0.30; 'one)': 0.30; 'relying': 0.30; 'sun,': 0.30; 'expression': 0.32; 'remaining': 0.32; "isn't": 0.33; 'to:addr:python-list': 0.33; 'assignment': 0.34; 'implies': 0.34; 'statement,': 0.34; 'issue': 0.36; 'skip:" 10': 0.36; 'languages': 0.37; 'but': 0.37; 'something': 0.37; 'strong': 0.38; 'somewhat': 0.38; 'steven': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'believe': 0.65; 'business': 0.70; 'subject:line': 0.73; 'map.': 0.84; 'print()': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HMQ5oL42Z0u2r4U9V6N0FyY4fEKinA+yz2hJ8mEecfk=; b=aI/B63QoMyc9CoCBXUwCJQyCQ6H+wuMeniSquElXf3A/XhQL8N+2KdoZfoIV8EnfNq H7IB+ABcLgxWZw4qFI1v21pLRLuGpQVs9VbR7BxN44cNMLRL8AjLAQQmr9Ie9aC8hyi2 mH2d0/pa6IcJe9IFjWiLclbhGytF6+Ezn/O/k= MIME-Version: 1.0 In-Reply-To: <4e47db26$0$30002$c3e8da3$5496439d@news.astraweb.com> References: <1312951356.77394.YahooMailNeo@web121518.mail.ne1.yahoo.com> <87fwl9hr4r.fsf@benfinney.id.au> <4e43cb2a$0$29986$c3e8da3$5496439d@news.astraweb.com> <74c2421f-28a0-4a8d-bf74-4eebacfb74f1@d7g2000vbv.googlegroups.com> <92b8f192-d7fc-4c60-87ad-71b12652f3a2@k8g2000yqk.googlegroups.com> <4e45ab9d$0$30002$c3e8da3$5496439d@news.astraweb.com> <4e4774ed$0$29982$c3e8da3$5496439d@news.astraweb.com> <4e47db26$0$30002$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 14 Aug 2011 16:39:53 +0100 Subject: Re: allow line break at operators From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313336402 news.xs4all.nl 23922 [2001:888:2000:d::a6]:32879 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11398 On Sun, Aug 14, 2011 at 3:26 PM, Steven D'Aprano wrote: > Yes, print as a statement was a mistake. But assignment as a statement, not > so much. Assignment as an expression in languages that have it tends to be > associated with frequent errors. > > The way I see it, if something operates by side-effect, then it has no > business being treated as an expression. Wikipedia (that well-known authority) lists among examples of side effects both "write data to a display or file" and "modify one of its arguments". This strongly implies that print() is a function that operates by side-effect, just as the assignment operator (in languages in which it is one) does. Treating "a=5" as an expression with the value 5 is no more relying on side effects than having "print('asdf')" an expression with the value None. I believe that print-as-a-function is a Good Thing, mainly because it can be used as an argument to such as map. Somewhat silly/trivial example: msgs=["Hello","World"] list(map(print,msgs)) I'm aware that assignment-as-an-expression has plenty of risks associated with it (the main one being the classic C issue of assignment inside a conditional - a feature that I use frequently myself, but which trips plenty of people up), which is a strong argument for its remaining a statement, but side effects isn't on its own. ChrisA