Re: Recursive generators and backtracking search
- From: "Diez B. Roggisch" <deets@xxxxxxxxxxxxx>
- Date: Sun, 30 Oct 2005 10:14:48 +0100
>> for pos in qsearch( pos ): >> yield pos
Um - do you really want to reuse the variable pos here? Yeah, it works, but this strikes me as very confusing. I'm not sure that it might not be implementation dependent.
Certainly not. pos is - and that is standard python semantics - just a name. Passing the bound _value_ of pos to some function and rebinding the the name afterwards is perfectly legal and will work in all implementations.
The question of style though remains. I wouldn't do that either, but what I frequntly do is something like this:
pos = "10" pos = int(pos)
Thus when I'm sort of transforming a value, I think it's ok, as the name still refers to the same conceptual entity.
Regards,
Diez .
- References:
- Recursive generators and backtracking search
- From: Talin
- Recursive generators and backtracking search
- Prev by Date: Re: How do I sort these?
- Next by Date: Re: query a port
- Previous by thread: Re: Recursive generators and backtracking search
- Next by thread: lambda functions within list comprehensions
- Index(es):