Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'args': 0.05; 'attribute': 0.07; 'rules.': 0.07; 'symbols': 0.07; 'typed': 0.07; 'python': 0.08; 'admit': 0.09; 'agrees': 0.09; 'alter': 0.09; 'dict': 0.09; 'minus': 0.09; 'tuple': 0.09; 'tuple.': 0.09; 'def': 0.13; 'blurb': 0.16; 'comparisons.': 0.16; 'constructs': 0.16; 'cryptic': 0.16; 'desirable,': 0.16; 'disagree,': 0.16; 'head,': 0.16; 'luckily': 0.16; 'names?': 0.16; 'received:192.168.0.11': 0.16; 'side.': 0.16; 'subject:syntax': 0.16; 'terse': 0.16; 'unpacking': 0.16; 'worse,': 0.16; 'syntax': 0.16; 'this:': 0.16; 'language': 0.17; 'seems': 0.20; 'programming': 0.21; 'suggests': 0.23; 'do,': 0.25; 'obviously': 0.25; 'code': 0.25; 'explicit': 0.29; 'explicitly': 0.29; 'sorry,': 0.29; 'weird': 0.29; 'argue': 0.30; 'cant': 0.30; 'clean.': 0.30; 'equality': 0.30; 'grasp': 0.30; 'semantics': 0.30; 'quite': 0.32; 'does': 0.32; 'list': 0.32; 'message- id:@gmail.com': 0.33; 'header:User-Agent:1': 0.33; 'rather': 0.33; 'instead': 0.33; 'agree': 0.33; 'rules': 0.34; 'to:addr:python- list': 0.34; 'to?': 0.34; 'things': 0.34; 'all.': 0.34; 'anything': 0.34; 'fundamental': 0.34; 'typical': 0.34; 'languages': 0.35; 'operations': 0.35; 'something': 0.35; 'are:': 0.35; 'however,': 0.36; 'none': 0.37; 'before.': 0.37; 'but': 0.37; 'list,': 0.37; 'received:192': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'not,': 0.37; 'some': 0.38; 'received:192.168.0': 0.38; 'received:209.85': 0.38; 'useful': 0.38; 'speak': 0.38; 'flexibility': 0.39; 'clearly': 0.39; 'should': 0.39; 'being': 0.39; 'everyone': 0.39; 'why': 0.39; "it's": 0.40; 'raw': 0.40; 'week.': 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'received:192.168': 0.40; 'more': 0.61; 'your': 0.61; 'below': 0.63; '90%': 0.64; 'fall': 0.64; 'questions,': 0.65; 'ever': 0.65; 'alternative': 0.65; 'plus': 0.66; 'here.': 0.66; 'making': 0.67; 'importantly,': 0.67; 'collection': 0.69; 'day': 0.69; 'wish': 0.70; "'equals'": 0.84; 'and:': 0.84; 'divides': 0.84; 'punctuation.': 0.84; 'realm': 0.84; 'mistaken': 0.91; 'unclear': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=owzjZcvJ7ob4SCttQpKNbRAlFn6cALe3kOMgEKd2ZU0=; b=Po7pmXWJwc2ORHkFquLPRukeW1vzHAcV6kIzJizxxI+FELCYqFaLZFf+Mf8sqHOygZ uNOFstkk4/ZGIg+sdwEBUIxsr0ih317i1/N9HnINWHfnIoOfErF4DWDxj+PJgx7HCUxB Sah53zgv8YfaffqOwbcIt8tAWf7BvH8kHBtOs= Date: Mon, 12 Dec 2011 00:44:38 +0100 From: Eelco Hoogendoorn User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Verbose and flexible args and kwargs syntax Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 79 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323647085 news.xs4all.nl 6965 [2001:888:2000:d::a6]:43159 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16993 > No more so than any other form of punctuation. Plus and minus + - may be > so common that just about everyone knows it, but how about | == @ % and > even . (dot)? None of these things will be obvious to newbies who have > never programmed before. Oh well. > Some things you just have to learn. Yes, some things you just have to learn. Nonetheless, I strongly prefer explicit logical operators over |, would much rather have 'equals' instead of ==, which is stylistic in line with 'is' and explicitly distinguishes between equality and identity comparisons. As for %; it is entirely unclear to me why that obscure operation ever got its own one-character symbol. Ill take 'mod', or even better, 'modulus' any day of the week. The dot is clearly quantitatively in another realm here. 90% of typical python code is attribute accesses. The dot is entirely unambigious and cannot be mistaken for anything else. It reads like a book. > It's a judgement call as to where a language divides "cryptic punctuation > line noise" and "useful short operators", and in my opinion * and ** tuple > and dict unpacking fall strongly on the "useful short operators" side. > Your opinion may differ, but luckily for me, the BDFL agrees with me :) I also agree that it is a value judgement as to which constructs get their own cryptic symbols and which do not, but the are some reasonable guidelines we should be able to agree upon. Obscure operations should not reserve any of the few available characters. Furthermore, the language should not just be formally consistent, but also easy to grasp at a glance, without deciphering subtle semantics of a blurb of weird characters. (some programming languages obviously disagree, but python, as far as I am allowed to speak for it, does not). And most importantly, if you cant come up with a terse syntax that does everything you want to do, the terse syntax should at best be an alternative to the verbose one. > It is also misleading because args are not collected into a list, but > into a tuple. In case you wanted a tuple youd write tuple(args), obviously. Exactly that added flexibility is half of my case in favor. Why shouldnt it be a list when I want it to? > Worse, it suggests that one should be able to generalise to > something like this: > def func(parg, str(args), int(kwargs), my_func(more_args)): > which is incoherent. Sorry, but I dont get this point at all. Does ** suggests one should be able to generalize to ***? The rules are the rules. The real questions, in my mind, are: 1) How useful is this added flexibility? Not insanely, but I can see it making a lot of code significantly more clean. And: 2) How fundamental is collection packing/unpacking? One can easily argue that it is indeed quite fundamental and therefore deserves its own terse symbols, I feel. However, if more flexibility is indeed deemed desirable, such terse syntax quickly gives way to a more verbose one. Can you come up with some terse symbols that will be able to express all of the below and dont make you wish you hadnt rather typed out the names? head, tuple(tail) = iterable head, list(tail) = iterable head, str(tail) = somestring head, generator(tail) = mygenerator And so on. If not, one has to admit that functionality is being sacrificed on the alter of terseness, which seems like a raw deal to me.