On Feb 21, 11:21 am, Lie Ryan lie.1...@gmail.com wrote:
On 02/21/10 19:27,lallouswrote:
snip
If the base defines the method and it was empty, then my C++ code
would still call the function. This is not optimal because I don't
want to go from C++ to Python if the _derived_ class does not
On Feb 22, 12:42 am, Gregory Ewing greg.ew...@canterbury.ac.nz
wrote:
lallouswrote:
If the base defines the method and it was empty, then my C++ code
would still call the function. This is not optimal because I don't
want to go from C++ to Python if the _derived_ class does not
implement
lallous wrote:
I still prefer not to call at all, even if it was an empty function.
Regards,
Elias
Is there any way we could convince you that there is no point caring
about this ? Even if you were trying to optimize speed, it would still
require proof that an empty function is part of
In article 38ddd614-583c-430d-b998-214bd6360...@b2g2000yqi.googlegroups.com,
lallous elias.bachaal...@gmail.com wrote:
On Feb 22, 12:42=A0am, Gregory Ewing greg.ew...@canterbury.ac.nz
wrote:
lallouswrote:
If the base defines the method and it was empty, then my C++ code
would still call the
Arnaud Delobelle wrote:
lallous elias.bachaal...@gmail.com writes:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
On Feb 20, 6:08 pm, Martin v. Loewis mar...@v.loewis.de wrote:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
�...@param param1: ...
�...@param param2: ...
raise NotImplementedError,
Thanks everyone for the answers.
The dispatcher() is actually sits in C++ code.
So my code receives an object that is an instance of the base class,
it PyObject_GetAttrString(py_obj, 'funcname'). If the attribute exists
I will call PyObject_CallMethod on it.
If the base defines the method and
That's not true. Currently, the hasattr() call would report that cb is
available, when it is actually not implemented. It would be possible to
do something like
if hasattr(c, 'cb') and not is_pure(c.cb):
c.cb(Hello, World)
is_pure could, for example, look at a function attribute of
On 02/21/10 19:27, lallous wrote:
snip
If the base defines the method and it was empty, then my C++ code
would still call the function. This is not optimal because I don't
want to go from C++ to Python if the _derived_ class does not
implement the cb.
That sounds like a microoptimization;
lallous wrote:
If the base defines the method and it was empty, then my C++ code
would still call the function. This is not optimal because I don't
want to go from C++ to Python if the _derived_ class does not
implement the cb.
I would simply not implement the method at all in the base
class.
lallous wrote:
Hello
How can I do something similar to pure virtual functions in C++ ?
See, for example
http://code.activestate.com/recipes/266468/
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
Am 20.02.10 17:12, schrieb lallous:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param param2: ...
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param param2: ...
raise NotImplementedError, Implement me
# Dispatcher function that calls 'cb' only if 'cb' is implemented
Sorry, I totally mis-read the OP, too tired. You are right of course.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
On Saturday 20 February 2010 11:46:42 Diez B. Roggisch wrote:
Am 20.02.10 17:12, schrieb lallous:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
lallous wrote:
How can I do something similar to pure virtual functions in C++ ?
http://docs.python.org/library/abc.html#abc.abstractmethod
Peter
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 20 Feb 2010 08:12:01 -0800, lallous wrote:
How can I do something similar to pure virtual functions in C++ ?
From what you want, it seems like you want cb() to not be called if it
isn't implemented in the derived class; this isn't really what pure
virtual functions in C++ do - pure
lallous elias.bachaal...@gmail.com writes:
Hello
How can I do something similar to pure virtual functions in C++ ?
Let us consider this:
class C1:
# Pure virtual
def cb(self, param1, param2):
This is a callback
@param param1: ...
@param
18 matches
Mail list logo