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
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
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:"
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:"
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
> > 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
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
>
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
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.
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
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
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:
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.
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.
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
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
16 matches
Mail list logo