Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'exercise': 0.04; 'one?': 0.05; 'subject: -- ': 0.07; 'subject:bug': 0.07; 'wednesday,': 0.07; 'optimizing': 0.09; 'spec': 0.09; 'def': 0.12; '11:09': 0.16; 'fuzzy': 0.16; 'iterable': 0.16; 'loops': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'thu,': 0.19; 'seems': 0.21; '>>>': 0.22; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'compared': 0.30; 'message-id:@mail.gmail.com': 0.30; 'helpful.': 0.31; 'class': 0.32; 'url:python': 0.33; 'maybe': 0.34; 'subject: (': 0.35; 'etc': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'sequence': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'two': 0.37; 'depends': 0.38; 'url:library': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'numbers': 0.61; 'url:3': 0.61; 'first': 0.61; 'information': 0.63; 'such': 0.63; 'central': 0.64; 'map': 0.64; '30,': 0.65; 'abc': 0.84; 'toy': 0.84; 'ware': 0.91 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 :content-type; bh=/aZP4EBSQgCKL7sQYL2Y9utvHJJ9LOjF1phmuDywMnk=; b=Jcx9KcCqub7+oL4JNGgokWwoqN63AjtqYJoiLNZmG2cLD1J0qXOkCswxD5ELvStVLW NLmluHAI4NZq3Rp3pgKSVfi3x2CgOnyVWFVemvrqIAbM1LPJh+aFvRe9Sa1gXkAeJisI 31CzaYkgrWgpxJgqsMPbfwr19Vp89cF863edMoJ9icloVmGdX30iSqZf8UTbpLCh3/rO rzIkRYb5DGMrhPcRuFojVVJIHQFOAGxVks48vxFn4NV/C+9Z4a3tM82xje97sHEpa4N8 tO0Q4y3+pLYvyO0rgOiqRVyZXDqFfRLioN7i/A0nUonjgEpuF49Dahe0UyT/lKDRCckz zRgg== X-Received: by 10.70.34.206 with SMTP id b14mr12755493pdj.10.1414689123019; Thu, 30 Oct 2014 10:12:03 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <94e3143a-c9ab-433d-8b3d-6ab296de14d9@googlegroups.com> <593c0099-770f-48cd-b7ba-22154b00f130@googlegroups.com> <525eb5e7-c221-4336-8c9a-aafb4c545f51@googlegroups.com> From: Ian Kelly Date: Thu, 30 Oct 2014 11:11:22 -0600 Subject: Re: Finding way around ABCs (was What for -- for? (was A bug?)) To: Python Content-Type: text/plain; charset=UTF-8 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414689131 news.xs4all.nl 2867 [2001:888:2000:d::a6]:44453 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79959 On Thu, Oct 30, 2014 at 11:09 AM, Ian Kelly wrote: > On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody wrote: >> On Wednesday, October 29, 2014 11:49:27 AM UTC+5:30, Zachary Ware wrote: >>> On Wed, Oct 29, 2014 at 1:11 AM, Rustom Mody wrote: >>> > On Wednesday, October 29, 2014 11:10:06 AM UTC+5:30, Zachary Ware wrote: >>> >> Of course, that's 3 (progressively shorter) loops to get the names of >>> >> the ABCs of a class compared to 1 (fairly short in the first place) >>> >> loop for a map of relationships to all available ABCs, but optimizing >>> >> such a toy as this would just be an exercise in futility :) >>> > >>> > Not so. >>> > >>> > The charm of introspection is that the introspection >>> > itself can be introspected. >>> > For that to be convincing there needs to be a good combo >>> > of clarity and succinctness. In particular why not reduce >>> > the two functions to one? >>> > >>> > def get_abc_names(cls): >>> > return [abc.__name__ for abc in abcs if issubclass(cls,abc)] >>> >>> Well, it depends on what you actually want, the spec has been a bit fuzzy ;) >> >> Thanks for this much -- its helpful. >> Regarding ABCs -- is there a central documentation for them: >> >> "What exactly is a sequence or iterable or etc protocol?" >> >> This information seems to be strewn all over the place but systematically. > > Maybe the glossary? Also the documentation for the collections.abc and numbers modules: https://docs.python.org/3/library/collections.abc.html https://docs.python.org/3/library/numbers.html