baffling bug in this bit of code!

erik_w erik.wilsher at iname.com
Thu Jul 4 02:48:22 EDT 2002


Daniel Jaeggi <jaeggi at NOSPAMembl-heidelberg.de> wrote in message 
> I'm reasonably new to python but I've used various other languages 
> before. The bug in the following bit of code has got me banging my head 
> as it should be trivial. If anyone can help, I'd be most grateful.
> 
> This snippet:
> 
>...snip code that locates max of x and y in nodes
You might be better off with this snippet of code (if you run 2.1 or newer):

nodes=self.nodes
locs_x = [nodes[n].location.x for n in nodes.keys()]
locs_y = [nodes[n].location.y for n in nodes.keys()]
max_x = max(locs_x)
max_y = max(locs_y)

Shorter and probably faster.

    BR
    EW



More information about the Python-list mailing list