Jean-Michel Pichavant a écrit :
(snip)
Sometimes the base is doing cool stuff but incomplete stuff which
requires knowledge only hold by the sub class. In my case the interface
is a high level interface for a software that can run on multiple
hardware platforms. Only the sub class has
Jean-Michel Pichavant a écrit :
Scott David Daniels wrote:
(snip)
But there _is_ one moment when you can check those things, then avoid
checking thereafter: object creation. So you can complicate your
__init__ (or __new__) with those checks that make sure you instantiate
only fully defined
Scott David Daniels wrote:
Jean-Michel Pichavant wrote:
Steven D'Aprano wrote:
On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote:
Sorry guys (means guys *and* gals :op ), I realized I've not been able
to describe precisely what I want to do. I'd like the base class to be
Jean-Michel Pichavant wrote:
scott.dani...@acm.org
That could do the trick, sparing me from writing additional code in each
methods. Thanks.
Why are you trying to reinvent the wheel? Python's abc module already
takes care of these details.
Christian
--
Christian Heimes wrote:
Jean-Michel Pichavant wrote:
talking about approaches:
1/
class Interface:
def foo(self):
if self.__class__.foo == Interface.foo:
raise NotImplementedError
2/
class Interface:
def foo(self):
self._foo()
def _foo(sef):
raise
Christian Heimes a écrit :
Jean-Michel Pichavant wrote:
scott.dani...@acm.org
That could do the trick, sparing me from writing additional code in
each methods. Thanks.
Why are you trying to reinvent the wheel? Python's abc module already
takes care of these details.
Christian
I'm working
Jean-Michel Pichavant wrote:
Steven D'Aprano wrote:
On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote:
Sorry guys (means guys *and* gals :op ), I realized I've not been able
to describe precisely what I want to do. I'd like the base class to be
virtual (aka abstract). However
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual class)
that will raise an exception only if called without being overridden ?
Currently in the virtual method I'm checking that the class of the
instance calling the method has defined that method as well.
Example:
Jean-Michel Pichavant wrote:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual class)
that will raise an exception only if called without being overridden ?
Currently in the virtual method I'm checking that the class of the
instance calling the method has defined
Jean-Michel Pichavant schrieb:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual class)
that will raise an exception only if called without being overridden ?
Currently in the virtual method I'm checking that the class of the
instance calling the method has defined
On Fri, 14 Aug 2009 16:49:47 +0200, Jean-Michel Pichavant wrote:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual class)
that will raise an exception only if called without being overridden ?
Currently in the virtual method I'm checking that the class of the
MRAB wrote:
Jean-Michel Pichavant wrote:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual
class) that will raise an exception only if called without being
overridden ?
Currently in the virtual method I'm checking that the class of the
instance calling the method
Jean-Michel Pichavant schrieb:
MRAB wrote:
Jean-Michel Pichavant wrote:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual
class) that will raise an exception only if called without being
overridden ?
Currently in the virtual method I'm checking that the class of
Diez B. Roggisch wrote:
Jean-Michel Pichavant schrieb:
MRAB wrote:
Jean-Michel Pichavant wrote:
Hi fellows,
Does anyone know a way to write virtual methods (in one virtual
class) that will raise an exception only if called without being
overridden ?
Currently in the virtual method I'm
Jean-Michel Pichavant wrote:
Your solution will work, for sure. The problem is that it will dumb down
the Base class interface, multiplying the number of methods by 2. This
would not be an issue in many cases, in mine there's already too much
meaningful methods in my class for me to add
On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote:
Sorry guys (means guys *and* gals :op ), I realized I've not been able
to describe precisely what I want to do. I'd like the base class to be
virtual (aka abstract). However it may be abstract but it does not mean
it cannot do
Nigel Rantor wrote:
Jean-Michel Pichavant wrote:
Your solution will work, for sure. The problem is that it will dumb
down the Base class interface, multiplying the number of methods by
2. This would not be an issue in many cases, in mine there's already
too much meaningful methods in my
Jean-Michel Pichavant wrote:
Nigel Rantor wrote:
Jean-Michel Pichavant wrote:
Your solution will work, for sure. The problem is that it will dumb
down the Base class interface, multiplying the number of methods by
2. This would not be an issue in many cases, in mine there's already
too
Jean-Michel Pichavant wrote:
div class=moz-text-flowed style=font-family: -moz-fixedNigel
Rantor wrote:
Jean-Michel Pichavant wrote:
Your solution will work, for sure. The problem is that it will dumb
down the Base class interface, multiplying the number of methods by
2. This would not be
Steven D'Aprano wrote:
On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote:
Sorry guys (means guys *and* gals :op ), I realized I've not been able
to describe precisely what I want to do. I'd like the base class to be
virtual (aka abstract). However it may be abstract but it
Dave Angel wrote:
Jean-Michel Pichavant wrote:
div class=moz-text-flowed style=font-family: -moz-fixedNigel
Rantor wrote:
Jean-Michel Pichavant wrote:
Your solution will work, for sure. The problem is that it will dumb
down the Base class interface, multiplying the number of methods by
2.
Jean-Michel Pichavant wrote:
talking about approaches:
1/
class Interface:
def foo(self):
if self.__class__.foo == Interface.foo:
raise NotImplementedError
2/
class Interface:
def foo(self):
self._foo()
def _foo(sef):
raise NotImplementedError
22 matches
Mail list logo