X-Received: by 10.224.110.68 with SMTP id m4mr4339853qap.2.1360370943356; Fri, 08 Feb 2013 16:49:03 -0800 (PST) X-Received: by 10.49.28.162 with SMTP id c2mr606527qeh.41.1360370943338; Fri, 08 Feb 2013 16:49:03 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!p13no4969323qai.0!news-out.google.com!k2ni21154qap.0!nntp.google.com!p13no3717711qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Fri, 8 Feb 2013 16:49:02 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.111.123; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj NNTP-Posting-Host: 70.196.111.123 References: <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> <7b027612-a07e-40f9-8ad2-3e95c5440482@googlegroups.com> <86872ad2-fda0-403b-9f18-d1cb18e41860@t32g2000yqd.googlegroups.com> <50039290$0$29978$c3e8da3$5496439d@news.astraweb.com> <9309333c-13a0-464c-bd94-9c682363b8c9@googlegroups.com> <511516db$0$29969$c3e8da3$5496439d@news.astraweb.com> <62c3e7bb-d023-43b4-b759-f424707fd346@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <75c82449-773e-4077-a6c9-e9cef08f845f@googlegroups.com> Subject: Re: Implicit conversion to boolean in if and while statements From: Rick Johnson Cc: python-list@python.org Injection-Date: Sat, 09 Feb 2013 00:49:03 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:38483 On Friday, February 8, 2013 6:05:54 PM UTC-6, Chris Angelico wrote: > The sum builtin works happily on any sequence of objects > that can be added together. It works as an excellent > flatten() method: > > >>> nested_list = [["q"], ["w","e"], ["r","t","u"], ["i","o","p"]] > >>> sum(nested_list,[]) > ['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p'] > >>> nested_list > [['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']] What the hell? Oh yeah, you must be using pike again. No, if it were pike the list would look like this: ({({"q"}), ({"w","e"}), ({"r","t","u"}), ({"i","o","p"})}) Of course you'd have to declare it first using an /expanded/ Java syntax: nested_list = array(array(string)) Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if want a few laughs. http://pike.lysator.liu.se/docs/tutorial/data_types/container_types.xml > I'm not sure what your definition of a numeric type is, but I suspect > that list(str) isn't part of it. Of course not.