for loop without variable
Duncan Booth
duncan.booth at invalid.invalid
Thu Jan 10 07:03:39 EST 2008
erik gartz <eegunnar at yahoo.com> 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. I can achieve the above
> with more lines of code like:
> i = 0
> while (i != 10):
> i += 1
> Is there a concise way to accomplish this without adding extra lines
> of codes? Thanks in advance for your help.
Google for: pylint unused
It pointed me at:
> Question:
> I've a function / method which is a callback where I do not have any
> control on received argument, and pylint is complaining about unused
> arguments. What can I do to avoid those warnings ?
>
> Answer:
> prefix (ui) the callback's name by cb_, as in cb_onclick(...). By doing
> so arguments usage won't be checked. Another solution is to use one of
> the name defined in the "dummy-variables" configuration variable for
> unused argument ("_" and "dummy" by default).
http://www.iaeste.or.at/doc/python2.3-pylint/html/FAQ.html
So it looks like you can use 'dummy' or add any other names you want to the
configuration.
More information about the Python-list
mailing list