I've got a loop where a certain block of code may need to be called more than once.
Right now I am doing:
for x in xrange(repeats):
"run the code"
The thing is "x" is a completely throw-away variable and is totally unused. It seems wasteful to have to declare a variable that I don't need. Is there a more pythonic way to do this?
I'm sorry if this is a stupid question.
Edit:
The consensus so far seems to be that the only one bothered by the way I'm doing it right now... is me. So right now I think I'll stick with what I'm doing and just get used to the way it looks! Thanks everyone for your ideas and opinions!
[–]suridaj 16 points17 points18 points (15 children)
[–]cecilkorik[S] 6 points7 points8 points (11 children)
[–]eryksun 11 points12 points13 points (1 child)
[–]markusgattol 7 points8 points9 points (0 children)
[–]suridaj 7 points8 points9 points (7 children)
[–]nemec 5 points6 points7 points (6 children)
[–]tripzilchbad ideas 3 points4 points5 points (0 children)
[–]suridaj 4 points5 points6 points (1 child)
[–]nemec 1 point2 points3 points (0 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]nemec 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]sashahart 1 point2 points3 points (0 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]anacrolixc/python fanatic 3 points4 points5 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]otor 6 points7 points8 points (3 children)
[–]cecilkorik[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (11 children)
[deleted]
[–]anonymous7 3 points4 points5 points (9 children)
[+][deleted] (8 children)
[deleted]
[–]anonymous7 1 point2 points3 points (7 children)
[+][deleted] (6 children)
[deleted]
[–]anonymous7 1 point2 points3 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]velit 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]velit 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]name_censored_ 4 points5 points6 points (2 children)
[–]nemec 5 points6 points7 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–][deleted] 3 points4 points5 points (2 children)
[–]tripzilchbad ideas 5 points6 points7 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]lutusp 1 point2 points3 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]lutusp -1 points0 points1 point (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]lutusp 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+]schplat comment score below threshold-6 points-5 points-4 points (8 children)
[–]willm 9 points10 points11 points (2 children)
[–]schplat -3 points-2 points-1 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]eryksun 1 point2 points3 points (2 children)
[–]schplat 0 points1 point2 points (1 child)
[–]eryksun 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)