Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'exercise': 0.04; 'importerror:': 0.07; 'subject: -- ': 0.07; 'subject:bug': 0.07; 'optimizing': 0.09; 'try:': 0.09; 'def': 0.12; 'collections': 0.16; 'loops': 0.16; 'subject:?)': 0.16; 'sure.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'wed,': 0.18; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'compared': 0.30; 'message- id:@mail.gmail.com': 0.30; 'class': 0.32; 'maybe': 0.34; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'filter': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'first': 0.61; 'such': 0.63; 'map': 0.64; 'combining': 0.68; 'abc': 0.84; 'toy': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=CeZQzuKfrZwO4+RJWwg/lFbvKAC3Wy7zS+xRmrCGDpk=; b=roULfmhHLDIFt1EokMBt8f9GWPDC/LNFFJai5Un37zYOwuzTNg8S3iTSS8JKaj8fCX hUWk0a0RhsK3SqxGcGA5afxu1fz+vEDaDE5G3gyKg2/85x4knETdI3dLKY3G3xmNDdFp /suKTM61gn6e/xoA6nG66UFRzJB+g5pnd1NWE0Braf0997uQsaKSqs3voU5CwOKfv5O1 eDyhPf3e7/IJGd8FAV/hgLQfONdaXRCNL9dmc+tWgCvAQwe1ByaOXT72+BJkfeQosUE9 JN6UEHRJ9sIMxB8qP79l95T54yvE+ywvtv85NwRZv2L1gxnOxc5+G4WwWq9wXdbRYgMn 0H2A== X-Received: by 10.202.203.149 with SMTP id b143mr477614oig.60.1414561191834; Tue, 28 Oct 2014 22:39:51 -0700 (PDT) MIME-Version: 1.0 Sender: zachary.ware@gmail.com In-Reply-To: References: <94e3143a-c9ab-433d-8b3d-6ab296de14d9@googlegroups.com> <593c0099-770f-48cd-b7ba-22154b00f130@googlegroups.com> From: Zachary Ware Date: Wed, 29 Oct 2014 00:39:31 -0500 X-Google-Sender-Auth: YuM9bHz_kDh1MGTQKsc30GDLs4Q Subject: Re: What for -- for? (was A bug?) To: "python-list@python.org" 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414561194 news.xs4all.nl 2872 [2001:888:2000:d::a6]:49156 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 1447942292 X-Received-Bytes: 4553 Xref: csiph.com comp.lang.python:79886 On Wed, Oct 29, 2014 at 12:15 AM, Rustom Mody wrote: > Maybe nicer to filter out the false's with a filter-false thus?? > > def ff(d): return [n for n in d if d[n]] Sure. Or, combining things: try: from collections import abc except ImportError: import collections as abc from abc import ABCMeta abcs = [o for o in vars(abc).values() if isinstance(o, ABCMeta)] def get_abcs(cls): return [abc for abc in abcs if issubclass(cls, abc)] def get_abc_names(cls): return [abc.__name__ for abc in get_abcs(cls)] 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 :) -- Zach