Missing member

John Machin sjmachin at lexicon.net
Sun Feb 4 18:12:47 EST 2007


On Feb 5, 9:45 am, "Mizipzor" <mizip... at gmail.com> wrote:
> I have some troubles with a member variable that seems to be missing
> in a class. In short, heres what I do; class A is the parent class, B
> inherits from A and C inherits from B (hope I used the right words
> there). Now, I create an instance of C, which calls A's __init__ which
> in turn creates all the member variables. Then I call C.move() (a
> function defined in A), but then, one of the variables seems to have
> become 'NoneType'.
>
> The code can be found here (Ive taken away unnecessery stuff):http://pastebin.com/875394
>
> The exact error is (which occur on line 15 in the pasted code):
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Line 15 is:
    self.pos += (self._direction * self.stats.speed)
So obviously(???) self._direction is None

What does line 8 do: self._direction = vector() ???

I'd suggest adding line 8.1:

assert self._direction is not None

> Any comments are welcome. :)

I doubt that you really mean that, so I have refrained from
commenting :-)

Cheers,
John




More information about the Python-list mailing list