On 10 July, 13:05, Johannes <dajo.m...@web.de> wrote:
> Hi list,
> i just tried the following pice of code and returned an unexcepted, but
> explainable behavior:
>
> sage: p = los[0][1]
> A lattice polytope: 3-dimensional, 4 vertices.
> sage: list(set([ p  for p in reduce (lambda x,y : x + y,[  f.points()
> for f in p.facets() ])]))
> [0, ... some list of points ]
> sage: p
> 34
>
> my old variable p = los[0][1] is overwritten by the one i used in the
> list comprehension. Is this the default sage or python behavior? or is
> this an bug in sage/python?

This is standard Python behaviour. A list comprehension doesn't have
its own scope, so the "p" used in the list comprehension overwrites
the other "p" previously declared in the same scope. I agree that this
can be annoying, but it's a fact of life in Python programming.

David

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to