On Jan 9, 8:35 pm, Dan Sommers <[EMAIL PROTECTED]> wrote: > On Wed, 09 Jan 2008 14:25:36 -0800, erik gartz wrote: > > Hi. I'd like to be able to write a loop such as: > > for i in range(10): > > pass > > but without the i variable. The reason for this is I'm using pylint and > > it complains about the unused variable i ... > > What does that loop do? (Not the loop you posted, but the "real" loop > in your application.) Perhaps python has another way to express what > you're doing. > > For example, if you're iterating over the elements of an array, or > through the lines of a file, or the keys of a dictionary, the "in" > operator may work better: > > for thing in array_or_file_or_dictionary: > do_something_with(thing) > > HTH, > Dan > > -- > Dan Sommers A death spiral goes clock- > <http://www.tombstonezero.net/dan/> wise north of the equator. > Atoms are not things. -- Werner Heisenberg -- Dilbert's PHB
The loop performs some actions with web services. The particular iteration I'm on isn't important to me. It is only important that I attempt the web services that number of times. If I succeed I obviously break out of the loop and the containing function (the function which has the loop in it) returns True. If all attempts fail the containing loop returns False. I guess based on the replies of everyone my best bet is to leave the code the way it is and suck up the warning from pylint. I don't want to turn the warning off because catching unused variables in the general is useful to me. Unfortunately, I don't *think* I can shut the warning for that line or function off, only for the entire file. Pylint gives you a rating of your quality of code which I think is really cool. This is a great motivation and helps me to push to "tighten the screws". However it is easy to get carried away with your rating.:-) -- http://mail.python.org/mailman/listinfo/python-list