0

I couldn't define it better in a one liner, so here it is in more detail (keep in mind, I'm relatively new to python and programming):

I'd like to iterate through the result of os.walk(path,topdown=True) (yields a 3-tuple), but i'd only like to use two of it's return values in my loop.

Is there a preferred way to do this in python? I'm currently using:

for root,_,files in os.walk(path,topdown=True):

but I read somwhere that using _ is discouraged in this kind of situation.

Thank you for your help in advance.

Cyberbird
  • 1
  • 1
  • 4
    You can either use `_` as you did, or assign a variable name and just not use that variable. The way you wrote it is fine, in fact that is typical convention indicating that you are deliberately ignoring that parameter. http://stackoverflow.com/a/5893186/2296458 – Cory Kramer May 28 '14 at 13:34
  • I'd say this settles it then :) Thank You! – Cyberbird May 28 '14 at 13:38

0 Answers0