Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'skip:[ 20': 0.03; 'problem:': 0.07; 'api': 0.09; 'skip:[ 30': 0.09; 'throw': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python- list': 0.10; 'def': 0.10; ':-)': 0.13; 'flattened.': 0.16; 'folks,': 0.16; 'object."""': 0.16; 'situation.': 0.16; 'wrote:': 0.17; 'tim': 0.18; 'define': 0.20; 'example': 0.23; "i've": 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; 'cc:addr:gmail.com': 0.27; 'chase': 0.29; 'though.': 0.29; 'probably': 0.29; 'class': 0.29; 'error': 0.30; 'resolution': 0.30; 'not.': 0.32; 'could': 0.32; 'cases,': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'needed': 0.35; 'built-in': 0.35; 'sequence': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'possible': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'where': 0.40; 'skip:" 10': 0.40; 'your': 0.60; 'solve': 0.62; 'behavior': 0.64; 'here': 0.65; 'wish': 0.70; 'hey,': 0.72; '2013': 0.84; 'loved.': 0.84; 'prescribed': 0.91; 'beneficial': 0.93 X-Received: by 10.49.58.167 with SMTP id s7mr826163qeq.5.1360545867802; Sun, 10 Feb 2013 17:24:27 -0800 (PST) Newsgroups: comp.lang.python Date: Sun, 10 Feb 2013 17:24:27 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.109.207; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj References: <680e50a4-6569-49cf-b369-0be450545d50@googlegroups.com> <5115c455$0$6574$c3e8da3$5496439d@news.astraweb.com> <511784b3$0$29988$c3e8da3$5496439d@news.astraweb.com> <6b7d7299-7ce3-401f-a950-04cea18af399@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 70.196.109.207 MIME-Version: 1.0 Subject: Re: LangWart: Method congestion from mutate multiplicty From: Rick Johnson To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org, Rick Johnson 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: , Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360548301 news.xs4all.nl 6888 [2001:888:2000:d::a6]:51674 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:38633 On Sunday, February 10, 2013 6:12:57 PM UTC-6, Tim Chase wrote: > What should you get if you flatten >=20 > [[[1,2],[3,4]],[[5,6],[7,8]]] >=20 > Should the result be >=20 > [[1,2],[3,4],[5,6],[7,8]] >=20 > or >=20 > [1,2,3,4,5,6,7,8] >=20 > I've needed both cases, depending on the situation. Well providing /every/ possible solution for /every/ possible answer to /ev= ery/ problem is not going to be possible unless you are willing to endure a= n endless amount of complexity.=20 My opinion is that flatten should should call seq.flatten() on all sub-sequ= ences. That seems like the only /reasonable/ resolution to allow. At least = sub-types could define how they get flattened.=20 However, that does not solve your problem: where you wish to flatten a sequ= ence down to a prescribed sub-depth; in your example: flatten(subdepth=3D1)= .=20 class Sequence(): """Hypothetical sequence object.""" def flatten(self, depth=3DINFINITY): # ... =20 py> seq =3D [[[1,2],[3,4]],0,[[5,6],[7,8]]] py> seq.flatten() [1,2,3,4,0,5,6,7,8] py> seq.flatten(depth=3D1) [[1,2,3,4],0,[5,6,7,8]] py> seq.flatten(depth=3D2) [1,2,3,4,0,5,6,7,8] py> seq.flatten(depth=3D3) # Throw error or just quietly return flat list??? I don't feel very good about this API though. But i admit it might be benef= icial to some folks. Should this example be the built-in behavior of Sequen= ce#flatten, probably not. But hey, here at pydev we add features that appea= se the masses because we want to be loved. So folks, get your votes in! :-)