Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'method.': 0.05; '[0]': 0.07; 'defines': 0.07; 'problem?': 0.07; 'repeated': 0.07; 'api': 0.09; '(although': 0.09; '[0,': 0.09; 'okay': 0.09; 'subclass': 0.09; 'subtle': 0.09; 'bug': 0.10; 'cc:addr:python-list': 0.10; 'thread': 0.11; 'library': 0.15; '(2,': 0.16; '0],': 0.16; '[2,': 0.16; 'backward': 0.16; 'benjamin': 0.16; 'cc:name:python list': 0.16; 'contrived': 0.16; 'expects': 0.16; 'general.': 0.16; 'input.': 0.16; 'losing': 0.16; 'wrote:': 0.17; 'passes': 0.17; 'tries': 0.17; '>>>': 0.18; 'subject:skip:i 10': 0.22; 'tuples': 0.22; 'cc:2**1': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'possibly': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'subject:list': 0.28; 'objects': 0.29; 'received:209.85.215.46': 0.30; 'error': 0.30; 'gets': 0.32; 'problem.': 0.32; 'could': 0.32; 'hopefully': 0.33; 'problem': 0.33; 'agree': 0.34; 'received:google.com': 0.34; 'list': 0.35; 'adds': 0.35; 'described': 0.35; 'lists.': 0.35; 'said,': 0.35; 'expected': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'different': 0.63; 'more': 0.63; 'sound': 0.65; 'absolutely': 0.84; 'oscar': 0.84 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:to :cc:content-type; bh=B0yRi+lNI+SRXbRS0W2Xiw3pJcc7dNSUv1oy1ouHQWc=; b=s9OyWS1hWj6+aeUIQl2YUskxDNDWjfH1MFLu0KJF0Cpi0ZhO5Ef3fJsVFcHmll7+Yf NiY8zomq0QP9QxsDgqPRLsdhyQtQtPPtNFU10V6iOF7KD9lH1rSV5bnCnzr4233J25o1 ZmnPGV2Kzqqnqp1hj62Bpa0ZPmbDf6w2xbDBnMheNlh+irZ3c6bRBs6ItSsQEskGUqxS vQkgEuo8IO61fQ4OO2Ar9AXpsU0zIjKQtImpFr/yaJqB1abdj1b4It4HxDXXCxUvcnGO d6z7Mj0rlnmTlCWWQ/qZftZ+nAR1X8HUikacv7CPf4XYAotIZwUMR63IwsBBjauai8C/ PM3w== MIME-Version: 1.0 In-Reply-To: References: <50978323$0$6908$e4fe514c@news2.news.xs4all.nl> <5098A55C.3090201@r3dsolutions.com> <5098C873.2000200@r3dsolutions.com> <509982CA.7050701@r3dsolutions.com> Date: Wed, 7 Nov 2012 23:06:27 +0000 Subject: Re: Multi-dimensional list initialization From: Oscar Benjamin To: Joshua Landau Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List , Gregory Ewing 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352329595 news.xs4all.nl 6905 [2001:888:2000:d::a6]:55763 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32911 On 7 November 2012 22:16, Joshua Landau wrote: > On 7 November 2012 14:00, Oscar Benjamin wrote: >> On 7 November 2012 13:39, Joshua Landau >> wrote: >> > On 7 November 2012 11:11, Oscar Benjamin >> > wrote: >> >> A more modest addition for the limited case described in this thread >> >> could >> >> be to use exponentiation: >> >> >> >> >>> [0] ** (2, 3) >> >> [[0, 0, 0], [0, 0, 0]] >> >> Exponentiation is expected to be asymmetric and is currently unused so >> there is no ambiguity. The problem is if someone has already >> subclassed list and added an exponentiation method. > > How is that a problem? They just wont get the functionality. This is absolutely contrived but: Library A defines a subclass of list that adds an exponentiation operator thinking that it's okay to still use these objects as lists. Library B has an API that expects a list and tries to use the list copy-exponentiation on its input. A user passes a list type object from library A into library B and hopefully gets an error but possibly gets a subtle bug that is hard to track down. It doesn't sound plausible to me but at least in principle there is a backward compatibility problem. > That said, losing: > [0] * (2, 3) == [0] * [2, 3] > would mean losing duck-typing in general. *Thus*, I fully agree with your > choice of exponentiation. Also there's no reason why tuples couldn't have the same exponentiation operator (although for them it would be no different from repeated multiplication). Oscar