Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64060

Re: Chanelling Guido - dict subclasses

Path csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jeanpierreda@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'nested': 0.07; 'wednesday,': 0.07; 'agree,': 0.09; 'structure,': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'check.': 0.16; 'inclined': 0.16; 'os.walk': 0.16; 'preserve': 0.16; 'subject:subclasses': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'typing': 0.19; 'written': 0.21; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'directory.': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'order.': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'rest': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; '(although': 0.31; 'anyone': 0.31; 'lists': 0.32; 'problem': 0.35; 'created': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'similar': 0.36; 'example,': 0.37; 'january': 0.37; 'list': 0.37; 'requiring': 0.38; 'rather': 0.38; 'structure': 0.39; 'john': 0.61; "you're": 0.61; 'kind': 0.63; 'choose': 0.64; 'different': 0.65; 'avoids': 0.84; 'otten': 0.84; 'dirty': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=+ynQ/YCitTlxCChMzlpUUw5cdO1rYGYyxe9hpBgZ/jA=; b=b0ryS65G5ZfoSe9qMQCKogjCMOVTYskfLnZtq5HA4N+7LsP93MWGJA99dmu8nFzuf2 Ugq6WWCqOBAB3NMR+ibu9jM5EDxAM9k94kz6JMV+OFpAD3Egx3xLYRWSO75OdNY9ZuzF BTp92ZXdnEnr/17u6cHoo0O2azSmPMoAzzD/SABR9xoQzCgtAqhrUBzFC9F7+rljU89l 8Cz45WPr047QFmwXWEk95pZyzwWs7jdjivzjDagP8kzsvIQHix1ckmxbHayx29l04meQ vl/KRxyWlqekPGVkWQDXfJo3jtlLSkAFbGtYelvyi3JCkhciaTREODNbxlTEdOCyneu+ 0J9g==
X-Received by 10.140.102.98 with SMTP id v89mr5054487qge.5.1389853893706; Wed, 15 Jan 2014 22:31:33 -0800 (PST)
MIME-Version 1.0
In-Reply-To <05ff1332-1776-4ac0-88b4-84f8fd323ce3@googlegroups.com>
References <52d5e408$0$29970$c3e8da3$5496439d@news.astraweb.com> <mailman.5494.1389775244.18130.python-list@python.org> <05ff1332-1776-4ac0-88b4-84f8fd323ce3@googlegroups.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date Wed, 15 Jan 2014 22:30:53 -0800
Subject Re: Chanelling Guido - dict subclasses
To John Ladasky <john_ladasky@sbcglobal.net>
Content-Type text/plain; charset=UTF-8
Cc "comp.lang.python" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5574.1389853901.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389853901 news.xs4all.nl 2842 [2001:888:2000:d::a6]:57378
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64060

Show key headers only | View raw


On Wed, Jan 15, 2014 at 8:51 AM, John Ladasky
<john_ladasky@sbcglobal.net> wrote:
> On Wednesday, January 15, 2014 12:40:33 AM UTC-8, Peter Otten wrote:
>> Personally I feel dirty whenever I write Python code that defeats duck-
>> typing -- so I would not /recommend/ any isinstance() check.
>
> While I am inclined to agree, I have yet to see a solution to the problem of flattening nested lists/tuples which avoids isinstance().  If anyone has written one, I would like to see it, and consider its merits.

As long as you're the one that created the nested list structure, you
can choose to create a different structure instead, one which doesn't
require typechecking values inside your structure.

For example, os.walk has a similar kind of problem; it uses separate
lists for the subdirectories and the rest of the files, rather than
requiring you to check each child to see if it is a directory. It can
do it this way because it doesn't need to preserve the interleaved
order of directories and files, but there's other solutions for you if
you do want to preserve that order. (Although they won't be as clean
as they would be in a language with ADTs)

-- Devin

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Chanelling Guido - dict subclasses Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-15 01:27 +0000
  Re: Chanelling Guido - dict subclasses Ned Batchelder <ned@nedbatchelder.com> - 2014-01-14 21:04 -0500
  Re: Chanelling Guido - dict subclasses Terry Reedy <tjreedy@udel.edu> - 2014-01-14 22:48 -0500
  Re: Chanelling Guido - dict subclasses F <f@hop2it.be> - 2014-01-15 07:00 +0000
  Re: Chanelling Guido - dict subclasses Peter Otten <__peter__@web.de> - 2014-01-15 09:40 +0100
    Re: Chanelling Guido - dict subclasses John Ladasky <john_ladasky@sbcglobal.net> - 2014-01-15 08:51 -0800
      Re: Chanelling Guido - dict subclasses Peter Otten <__peter__@web.de> - 2014-01-15 19:35 +0100
      Re: Chanelling Guido - dict subclasses Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-15 22:30 -0800
  Re: Chanelling Guido - dict subclasses Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-15 09:10 +0000
  Re: Chanelling Guido - dict subclasses Tim Chase <python.list@tim.thechases.com> - 2014-01-15 05:03 -0600
  Re: Chanelling Guido - dict subclasses Daniel da Silva <var.mail.daniel@gmail.com> - 2014-01-15 19:50 -0500
    Re: Chanelling Guido - dict subclasses Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-16 17:17 +1300

csiph-web