On 08Oct2013 01:20, [email protected] <[email protected]> wrote:
> I cant just subclassing doesent work. It seem the init method of the source
> class also calls out another class. And the problem is, i can subclass the
> other class to with the required function but the end result is that it
> doesent work, since the source class cant accsess the subclass functions.
>
> The source code is pykkar.
>
> https://courses.cs.ut.ee/all/MTAT.03.100/2012_fall/uploads/opik/_downloads/pykkar.py
>
> I want to add it a new ability called left(). I cant manipulate the source
> class, cause then my comp will be the only one where the program runs.
>
> class pykkar_l(Pykkar):
> def left(self):
> self._world.execute("left")
[...]
You normally need to call the superclasses' __init__ method as well.
Example:
def __init__(self):
Pykkar.__init__(self)
... any of your own init stuff ...
Likewise for your world_l class.
BTW, it is conventional to start class names with an upper case letters. Just
style, but it helps other people when reading your code.
Cheers,
--
Cameron Simpson <[email protected]>
It looks like you've got Mister Bus Error installed. - tjc
--
https://mail.python.org/mailman/listinfo/python-list