os.path.walk() to get full path of all files

Tim Golden mail at timgolden.me.uk
Thu Mar 17 05:08:10 EDT 2011


On 17/03/2011 08:58, Laurent Claessens wrote:
>
>> file_list = []
>> for root, _, filenames in os.walk(root_path):
>> for filename in filenames:
>> file_list.append(os.path.join(root, filename))
>
>
> What does the notation "_" stands for ? Is it a sort of /dev/null ?
>
> I know that in the terminal it represents the last printed text.

It's a convention for saying "I don't really care about this
particular value which is returned from that function". You
could, at your whim, use "dontcare" or "x" or whatever.

TJG



More information about the Python-list mailing list