Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!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; 'classes,': 0.05; 'sub': 0.09; 'subclasses': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '(the': 0.15; 'classes:': 0.16; 'cls': 0.16; 'correctly,': 0.16; 'sense,': 0.16; 'latter': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'common': 0.26; 'class': 0.29; 'classes': 0.30; 'help,': 0.32; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'gives': 0.39; 'further': 0.61; 'first': 0.61; 'safe': 0.63; 'decided': 0.65; 'account': 0.67 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:path:newsgroups:date:in-reply-to:complaints-to :injection-info:nntp-posting-host:references:user-agent :x-google-web-client:x-google-ip:mime-version:message-id:subject :from:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=l7alvomzAA+w5WWelyUh7Mk+YH9K85zJHQZ9yh9rCu8=; b=bB2AW38A83TeLdlump94nw76eyNVPPO282pL1HSs+pSSUmjbxHl3KI95gvS0YHkzgS gOz7LXo7OAMUa6wjve1FigcbtHHsKkmol8+mDk5tdo5JiNsySfotDbY8gRWj7j4Vn4mC aowDZVTR0EBJt1AdnkzuOA1Rg87jda4RiEXXUGBeDst0AgOkazWJfFAn30FKFvxNfEkT I/jp5H/9whlG3/IuyWRMrHTPIZFK+51zoh/oe8BsMTDE7a4mFTupm8iGlgw1WJcaCGK9 xUqIV1BAxCDyszOJCA+MA4ZDNIj1Aq2WyD2aAFHY0pM6cn3+woONHEBHGy9AXQvjzi64 iF9g== X-Received: by 10.49.116.139 with SMTP id jw11mr1678645qeb.12.1359161297817; Fri, 25 Jan 2013 16:48:17 -0800 (PST) Newsgroups: comp.lang.python Date: Fri, 25 Jan 2013 16:48:17 -0800 (PST) In-Reply-To: <0d837f4c-c4a7-4df6-978c-b62a10ef9d70@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.209.206.24; posting-account=gpkyRAoAAABlPh1mY6Zt264UpMjIbxAz References: <766ec7eb-ab43-4c17-8073-3a0e6a8b89ea@googlegroups.com> <0d837f4c-c4a7-4df6-978c-b62a10ef9d70@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.209.206.24 MIME-Version: 1.0 Subject: Re: finding abc's From: lars van gemerden To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlpPU69r0/qg61y6T0fWcvLr4NGJ+jEkiU5ZfI7zLvS9K2YY51i0cKPL5l9tA89lzGG8Gbc Cc: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359161309 news.xs4all.nl 6985 [2001:888:2000:d::a6]:59444 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37706 for future reference, i decided to go with 2 functions: def common_bases(classes): if not len(classes): return None common =3D set(classes.pop().mro()) for cls in classes: common.intersection_update(cls.mro()) #all subclasses in common = =20 return [cls for cls in common if not any(sub in common for sub in cls._= _subclasses__())] #the classes of which no subclasses are present def unique_common_base(classes): while len(classes) > 1: classes =3D common_bases(classes) return classes.pop() if i tested and understood correctly, they only take classes in the mro() i= nto account (which might include abc's), the first gives all common base cl= asses, the second recursively reduces further to one single class (the latt= er might not make to much sense, but in my program it is a safe bet for rar= e cases). Thanks again for the help, Cheers, Lars