Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '(at': 0.04; 'value,': 0.04; 'subject:Python': 0.06; 'suppose': 0.07; 'ambiguity': 0.09; 'calls.': 0.09; 'newline': 0.09; 'operator,': 0.09; 'subject:language': 0.09; 'thats': 0.09; 'trailing': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'missed': 0.12; '(both': 0.16; 'braces': 0.16; 'call)': 0.16; 'comma': 0.16; 'confuse': 0.16; 'dictionaries': 0.16; 'dictionary.': 0.16; 'element,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gained': 0.16; 'mandate': 0.16; 'notation,': 0.16; 'parentheses': 0.16; 'separator,': 0.16; 'subject: \n ': 0.16; 'subject:?)': 0.16; 'subject:unicode': 0.16; 'terribly': 0.16; 'token,': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'tuple.': 0.16; 'tuple;': 0.16; 'language': 0.16; 'acquired': 0.19; 'meant': 0.20; 'solution.': 0.20; 'seems': 0.21; '>>>': 0.22; 'issue.': 0.22; 'cc:addr:python.org': 0.22; '(by': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '(maybe': 0.31; '25,': 0.31; 'follows': 0.31; 'grouping': 0.31; 'lot.': 0.31; 'them?': 0.31; 'tuples': 0.31; 'class': 0.32; 'another': 0.32; 'text': 0.33; 'open': 0.33; 'everyone': 0.33; 'something': 0.35; 'case,': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'otherwise.': 0.36; 'doing': 0.36; 'changing': 0.37; 'bringing': 0.38; 'mapping': 0.38; 'pm,': 0.38; 'previous': 0.38; 'short': 0.38; 'solve': 0.60; 'no.': 0.61; 'simple': 0.61; 'back': 0.62; 'name': 0.63; 'talking': 0.65; 'between': 0.67; 'dont': 0.67; 'mar': 0.68; 'special': 0.74; 'yourself': 0.78; 'subject:this': 0.83; 'ambiguous': 0.84; 'borrow': 0.84; 'calls,': 0.84; 'confusing': 0.84; 'confusion.': 0.84; 'different.': 0.84; 'whereby': 0.84; 'to:none': 0.92; 'imagine': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KAjLbRM9UUCeVCSDu71aOXzD2SMojG0AOkDOsqisGcQ=; b=giD00nkmA/ByDUHrU9CYgpEfm1JWi3/lV5PcgBTh69z2RN0+XsSiqKzLPlcZn/l8oH kX2s1x8RR7GnqBQHvNdalgR/jONS4SnR95lW7pQaniRwgmiiBHe9cTaYyMGftbU2btXg qQUSI2BS8ccBNTjiwiqVPrAsZTuQUU3r5QactAOA0zy84Yh66AbKjop6mVaENYVfhECT l/El+isL3LWAGKqKG+xxauFryB1jHl+TnHazmTVvsBK1qPLuSocCoQts+6ky63TA+gwA yNes/j0jemfBHWNgd0X8yYfFCtMSnpZ+j7lbyfwwYYxvLG+ysQz1LqW6SWVnpQ0Z6Alc tG+A== MIME-Version: 1.0 X-Received: by 10.66.164.229 with SMTP id yt5mr76845841pab.67.1395720870219; Mon, 24 Mar 2014 21:14:30 -0700 (PDT) In-Reply-To: <53060a97-44fb-4e53-a7a7-d5eeed416f62@googlegroups.com> References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <10101874-2995-4acd-9851-989603f052e3@googlegroups.com> <532d5bd9$0$29994$c3e8da3$5496439d@news.astraweb.com> <0b78649a-16b3-4410-8258-e859578d62be@googlegroups.com> <53060a97-44fb-4e53-a7a7-d5eeed416f62@googlegroups.com> Date: Tue, 25 Mar 2014 15:14:30 +1100 Subject: Re: Time we switched to unicode? (was Explanation of this Python language feature?) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395720873 news.xs4all.nl 2880 [2001:888:2000:d::a6]:37952 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68950 On Tue, Mar 25, 2014 at 2:56 PM, Rustom Mody > I don't know about the difference between {} in set theory and Python, >> but the multiple uses of () actually boil down to two: > > In set theory {} makes sets > In python {} makes dictionaries That's a backward-compatibility issue. Braces in Python meant a dictionary before it acquired a set type (at least, so I learned in history class - I wasn't using Python back then), so empty braces have to continue to mean empty dictionary. I sympathize with the confusion, but short of confusing everyone terribly by changing dicts to use something other than braces (maybe borrow Pike's mapping notation, ([ ])??), I don't really see a solution. >> 1) Grouping, which includes tuples; there's a special case whereby >> grouping nothing makes a zero-item tuple, but everything else is just >> the comma > >> 2) Functions (both definition and call) > >> Disambiguating them might be of some small value, but since they're >> the same in pretty much every language under the sun, it would feel > > What 'they'?? I dont get: If you are talking of disambiguating function definition and call -- yeah thats overkill No no. Disambiguating grouping and fuction definition/call. There's no reason to have definition and call of functions differ. > If you are talking of overlap between tuples parentheses and function (call) > well consider > f(x,y) vs f((x,y)) vs (x,y) vs ((x,y)) > Paren vs tuples: why do we need to write (x,) not (x) > > All this is because () is doing triple-duty Tuples don't use parentheses. You only confuse yourself when you insist on that. The only case with parens that actually makes a tuple is the special empty tuple; imagine if that were given a name instead, like "Empty". That would solve that confusion. There's another minorly special case, and that's that the trailing comma is mandatory on a one-item tuple. In all others, it's optional, but the one-item tuple would be ambiguous otherwise. >>> len((1,2,3,)) 3 >>> len((1,2,)) 2 >>> len((1,)) 1 (By the way, bringing in another discussion: The comma isn't part of the element, nor is it exactly a separator, nor is it exactly a terminator. Just like a newline in a text file.) So the only ambiguity is between function calls and grouping. Tuples are just part of grouping, in that you need to disambiguate a one-tuple-arg function call from a multiple-arg function call - as in the above len() calls. And that's where I think it would be highly confusing to mandate something different. Suppose we used $( )$ for function calls, and ^( )^ for grouping: x = ^(1 + 2)^ * 3 y = range$(x)$ What have we gained by distinguishing them? Not a lot. If an open parenthesis immediately follows another token, it's calling that previous token; if it follows an operator, it's grouping. Seems pretty simple to me. (Cue the spate of emails pointing out something I've missed that breaks that rule, in which case call it a rule of thumb.) ChrisA