Friday Finking: Abstract Base Classes - love or hate

2021-01-14 Thread dn via Python-list
Do you make frequent use of Abstract Base Classes (ABCs), prefer to use an ordinary super-class for the same purpose, or steer-clear? Are they more-usually employed when the project includes an extensive design stage, and the meta-class integral to some hierarchy of entities? Previous Friday

Re: Question about abstract base classes and abstract properties -- Python 2.7

2017-01-10 Thread Steven D'Aprano
On Wednesday 11 January 2017 12:26, Gerald Britton wrote: > I was rereading the 2.7 docs about abstract base classes the other day. I > found this line in the usage section of the abc.abstractproperty function: > > "This defines a read-only property; you can also define a read

Re: Question about abstract base classes and abstract properties -- Python 2.7

2017-01-10 Thread Gerald Britton
I was rereading the 2.7 docs about abstract base classes the other day. I found this line in the usage section of the abc.abstractproperty function: "This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:"

Question about abstract base classes and abstract properties -- Python 2.7

2016-10-22 Thread Gerald Britton
I was rereading the 2.7 docs about abstract base classes the other day. I found this line in the usage section of the abc.abstractproperty function: "This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:"

Question about abstract base classes and abstract properties -- Python 2.7

2016-09-04 Thread Gerald Britton
I was rereading the 2.7 docs about abstract base classes the other day. I found this: "This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:" along with an example. so I copied the example and put i

Re: Voluntary Abstract Base Classes

2007-06-29 Thread Daniel Nogradi
> > Well, the short question is: what are they? I've read Guido's python > > 3000 status report on > > http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he > > mentions ABC's but don't quite understand what the whole story is > > about. > > The story is at PEP 3119: > http://www.python

Re: Voluntary Abstract Base Classes

2007-06-29 Thread Eduardo \"EdCrypt\" O. Padoan
On 6/29/07, Daniel Nogradi <[EMAIL PROTECTED]> wrote: > Hi list, > > Well, the short question is: what are they? I've read Guido's python > 3000 status report on > http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he > mentions ABC's but don't quite understand what the whole story is >

Re: Voluntary Abstract Base Classes

2007-06-29 Thread James Stroud
Daniel Nogradi wrote: > Hi list, > > Well, the short question is: what are they? I've read Guido's python > 3000 status report on > http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he > mentions ABC's but don't quite understand what the whole story is > about. > > Anyone has good us

Voluntary Abstract Base Classes

2007-06-29 Thread Daniel Nogradi
Hi list, Well, the short question is: what are they? I've read Guido's python 3000 status report on http://www.artima.com/weblogs/viewpost.jsp?thread=208549 where he mentions ABC's but don't quite understand what the whole story is about. Anyone has good use cases? Daniel -- http://mail.python.

Re: Abstract Base Classes

2005-11-13 Thread Steven D'Aprano
Ben Finney wrote: > Ben Finney <[EMAIL PROTECTED]> wrote: > >>I want my modules to (sometimes) define an abstract base exception >>class, that all other exceptions in that module inherit from. > > > [re-posting with the implementation properly foo-ified] Isn't the proper Python idiom to use Mon

Re: Abstract Base Classes

2005-11-13 Thread Ben Finney
ry: foo.do_stuff(bar) except FooException, e: special_error_handler(e) Any more comment on this technique? Any other significant use cases for abstract base classes? -- \ "For man, as for flower and beast and bird, the supreme triumph | `\ is to be most vividly, most

Re: Abstract Base Classes

2005-11-13 Thread Ben Finney
t; This allows the exceptions for the module to behave similarly to their leftmost base exception; but because they all inherit from the abstract base class exception for the module, it also allows for this idiom: import foo try: foo.do_stuff(bar) except FooException, e:

Re: Abstract Base Classes

2005-11-11 Thread Colin J. Williams
Ben Finney wrote: > Howdy all, > > Okay, so Guido doesn't like Abstract Base Classes[0], and interfaces > are the way of the future[1]. But they're not here now, and I > understand ABCs better. This is a very interesting discussion - not all of it understandable to me.

Re: Abstract Base Classes

2005-11-10 Thread Ben Finney
Mike Meyer <[EMAIL PROTECTED]> wrote: > class FooException(Exception): > def __init__(self): > if self.__class__ == FooException: > raise NotImplementedError, >"FooException is an abstract class for exceptions" Shall try this when I get the chance.

Re: Abstract Base Classes

2005-11-10 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > I've tried doing this in the __init__(): > > class FooException(Exception): > """ Base class for all FooModule exceptions """ > def __init__(self): > raise NotImplementedError, \ > "%s is an abstract class for

Abstract Base Classes

2005-11-10 Thread Ben Finney
Howdy all, Okay, so Guido doesn't like Abstract Base Classes[0], and interfaces are the way of the future[1]. But they're not here now, and I understand ABCs better. I want my modules to (sometimes) define an abstract base exception class, that all other exceptions in that module in