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 sub
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 knowledg
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 w
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 No
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
--
http://mail.python.org/mailman/listinf
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
virtu
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 i
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
Pleas
Dave Angel wrote:
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'
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 does
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 much
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 much
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 clas
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 d
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 artif
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 check
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 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 ha
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
>
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 th
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 that
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:
c
22 matches
Mail list logo