Newsgroups: comp.lang.python
From: Chris Angelico <ros...@gmail.com>
Date: Mon, 12 Dec 2011 00:09:56 +1100
Local: Sun, Dec 11 2011 8:09 am
Subject: Re: Verbose and flexible args and kwargs syntax
On Sun, Dec 11, 2011 at 11:39 PM, Duncan Booth
<duncan.bo...@invalid.invalid> wrote:
Yes, that's just a strict keywordification of the * and ** symbols.
> Chris Angelico <ros...@gmail.com> wrote: > If it used keywords then you could keep symmetry quite easily: > def anyargs(arglist args, argdict kwargs):
> and you would have the advantage of two new keywords that people could
The same argument could be made for eliminating the standard algebraic + operator and replacing it with a keyword "__add__". I don't think that's worthwhile. The OP suggested using 'dict' and 'list' themselves as the keywords,
def anyargs(pack list args, pack dict kwargs):
With this syntax, what happens if you muck up list/dict? Or
def anyargs(pack list args, pack dict kwargs):
which breaks the symmetry, and doesn't say which one you're doing -
The verbose syntax has a lot going for it, but it's rather verbose.
foo = ["asdf", "qwer", {1:2, 3:4}]
$foo = array("asdf", "qwer", array(1=>2, 3=>4))
Is it more Pythonic to use explicitly-named types, or to have simple
>> Another issue: You suggest being able to use "attrdict" or some other
Ah. Curious. I've not done much with multiple inheritance in Python
>> dict subclass. This means that, rather than being a language >> construct, this will involve a name lookup. And what happens if you >> have a class that subclasses both list and dict? Will it get the >> positional args, the keyword args, or both? > Irrelevant, you can't subclass both list and dict:
(come to think of it, I don't recall when I last used MI in _any_ language). In any case, there's still the potential unclarity as to _which_ of dict and list is the one that's been inherited, which requires a run-time lookup to solve. ChrisA
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||