Re: finding abc's

2013-01-25 Thread lars van gemerden
for future reference, i decided to go with 2 functions: def common_bases(classes): if not len(classes): return None common = set(classes.pop().mro()) for cls in classes: common.intersection_update(cls.mro()) #all subclasses in common return [cls for cls in co

Re: finding abc's

2013-01-25 Thread lars van gemerden
On Friday, January 25, 2013 8:08:18 PM UTC+1, Peter Otten wrote: > lars van gemerden wrote: > > > > > Hi all, > > > > > > i was writing a function to determine the common base class of a number > > > classes: > > > > > > def common_base(classes): > > > if not len(classes): > > >

Re: finding abc's

2013-01-25 Thread lars van gemerden
On Friday, January 25, 2013 8:04:32 PM UTC+1, Ian wrote: > On Fri, Jan 25, 2013 at 10:40 AM, lars van gemerden > > wrote: > > > Hi all, > > > > > > i was writing a function to determine the common base class of a number > > classes: > > > > > [...] > > > > > > and ran common_base(int, flo

Re: finding abc's

2013-01-25 Thread Peter Otten
lars van gemerden wrote: > Hi all, > > i was writing a function to determine the common base class of a number > classes: > > def common_base(classes): > if not len(classes): > return None > common = set(classes.pop().mro()) > for cls in classes: > common.intersection

Re: finding abc's

2013-01-25 Thread Ian Kelly
On Fri, Jan 25, 2013 at 10:40 AM, lars van gemerden wrote: > Hi all, > > i was writing a function to determine the common base class of a number > classes: > [...] > > and ran common_base(int, float), hoping to get numbers.Number. > > this did not work because abstract base classes are not always