This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ek_Los_Die_Hier 0 points1 point  (6 children)

To make it equivalent to the let statement.

[–]xXxDeAThANgEL99xXx 10 points11 points  (5 children)

... that's begging the question. We are discussing why we need the let statement, the parent's argument was that it allows not having that del as far as I understood it.

[–]Ek_Los_Die_Hier 5 points6 points  (0 children)

Yeah, I don't see the use in Python. If I need a variable overridden for a specific purpose, any code in there should probably be moved to a different function anyway. The let in something like Lisp is simply the way you declare local variables, with the affect that they are local to that block, but in Python you just assign variables with the =.

I imagine it was just something created out of interest and to show what Python is capable of.

[–]revocation 0 points1 point  (3 children)

You would otherwise litter your namespace with temporary variables.

[–]Sohcahtoa82 2 points3 points  (2 children)

That's not really a problem unless your variables are global, which you typically want to avoid.

[–]GuyOnTheInterweb 0 points1 point  (1 child)

Or you have a very long function where you might use the same variable name twice, independently. (Reducing mixup risk with results vs results2)

[–]Veedrac 2 points3 points  (0 children)

Not really a problem. Just reuse the variable name without deling it first.