Finding way around ABCs (was What for -- for? (was A bug?))

2014-10-30 Thread Rustom Mody
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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding way around ABCs (was What for -- for? (was A bug?))

2014-10-30 Thread Ian Kelly
On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody rustompm...@gmail.com 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?

https://docs.python.org/3/glossary.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding way around ABCs (was What for -- for? (was A bug?))

2014-10-30 Thread Ian Kelly
On Thu, Oct 30, 2014 at 11:09 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Oct 30, 2014 at 11:01 AM, Rustom Mody rustompm...@gmail.com 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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding way around ABCs (was What for -- for? (was A bug?))

2014-10-30 Thread Rustom Mody
On Thursday, October 30, 2014 10:40:42 PM UTC+5:30, Ian 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?
 
 https://docs.python.org/3/glossary.html

Ummm...

I was looking for something more reference-ish, ie
More prolix for ABCs
And not containing random bits of unconnected data like
- What is CPython
- What is EAFP

Maybe there's something in the bowels of the C(Python)-code?
-- 
https://mail.python.org/mailman/listinfo/python-list