[Tutor] FW: robots question

Peter Otten __peter__ at web.de
Thu Sep 16 20:10:02 CEST 2010


Roelof Wobben wrote:

> I change everything to this :

> def check_collisions(robots, junk, player):

>         defeated = check_collisions(robots, player, junk)

Do you see the problem?

>         print "type robots", type(robots)
>         print "type junk", type(junk)
>         print "type player", type(player)

Adding print statements for debugging purposes is a good approach.

> And now Im getting this message :
> 
> ** Message: pygobject_register_sinkfunc is deprecated (GtkWindow)
> ** Message: pygobject_register_sinkfunc is deprecated (GtkInvisible)
> ** Message: pygobject_register_sinkfunc is deprecated (GtkObject)
> <type 'list'>
> type robotsTraceback (most recent call last):
>  <type 'list'>
> type junk <type 'list'>
> type player <type 'dict'>
>   File "/root/workspace/test2/src/test.py", line 125, in <module>
>     play_game()
>   File "/root/workspace/test2/src/test.py", line 111, in play_game
>     defeated = check_collisions(robots, player, junk)
>   File "/root/workspace/test2/src/test.py", line 74, in check_collisions
>     for thing in robots + junk:
> TypeError: can only concatenate list (not "dict") to list
> 
> So far I can see the problem is that player is a dict and the rest is a
> list.
> Is this the correct conclusion ?

It may be correct but it's a low-level view. A more appropriate description 
would be that you are trying to concatenate a list of robots with a player.

Peter



More information about the Tutor mailing list