weakref pitfall

Odalrick odalrick at hotmail.com
Sat Oct 20 10:46:30 EDT 2007


On 20 Okt, 16:21, Paul Hankin <paul.han... at gmail.com> wrote:

> The next stage in debugging is to think of a test that will prove your
> guess right or wrong. I'd remove weakrefs from your event manager and
> see if your code starts working.
>
> I'd suggest you're a bit confused about your event manager's API: you
> have register/deregister methods and are also using weakrefs to
> provide auto-deregistering. I don't know your code, but this looks
> like a mistake to me - can you justify (to yourself) that you need
> both ways?
>
> --
> Paul Hankin

Yes, I did a test with a standard dict and that removed the bug,
should have mentioned that.

And, no, I'm not sure I need both. Currently I'm using the standard
dict.

I'm fairly sure I'll need to manually deregister sometimes, buttons
and whatnot, but automatic deregistration sounds nice for later when
I'll have hundreds of sprites flying around.





More information about the Python-list mailing list