ignoring a part of returned tuples

2007-07-04 Thread noamtm
Hi,

Some functions, like os.walk(), return multiple items packed as a
tuple:

for (dirpath, dirnames, filenames) in os.walk(...):

Now, if you don't care about one of the tuple members, is there a
clean way to ignore it, in a way that no unused variable is being
created?

What I wanted is:
for (dirpath, , filenames) in os.walk(...):

But that doesn't work.

Thanks, Noam.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ignoring a part of returned tuples

2007-07-04 Thread noamtm
On Jul 4, 11:29 am, Bruno Desthuilliers  wrote:

> A common idiom is to use '_' for unused values, ie:
>
> for (dirpath, _, filenames) in os.walk(...):

That's what I need - this avoids PyLint telling me that I have an
unused variable, and also makes it clear that this value is not used.

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ignoring a part of returned tuples

2007-07-22 Thread noamtm
> Pylint also "allows" the name `dummy` without complaining.  That makes it
> even clearer and doesn't clash with the meaning of `_` when `gettext` is
> used.

Thanks, that's even better!

Noam.

-- 
http://mail.python.org/mailman/listinfo/python-list