←back to thread

498 points azhenley | 1 comments | | HN request time: 0.206s | source
Show context
sgarland ◴[] No.45770550[source]
Dumb question from a primarily Python programmer who mostly writes (sometimes lengthy) scripts: if you have a function doing multiple API calls - say, to different AWS endpoints with boto3 - would you be expected to have a different variable for each response? Or do you delete the variable after it’s handled, so the next one is “new?”
replies(3): >>45770602 #>>45770650 #>>45770806 #
TZubiri ◴[] No.45770602[source]
I think renaming an old variable is a common and sensible way to free a resource in python. If there are no valid names for a resource it will be garbage collected. Which is different in languages like C++ with manual memory management.

John Carmack is a C++ programmer apparently that still has a lot to learn in python.

replies(4): >>45770941 #>>45770988 #>>45773607 #>>45777177 #
ForHackernews ◴[] No.45770988[source]
But wouldn't you do that inside a function or a loop body?
replies(1): >>45771267 #
1. busfahrer ◴[] No.45771267[source]
In TFT, he mentions

> [...] outside of true iterative calculations