the usage of 'yield' keyword
Tim Golden
mail at timgolden.me.uk
Wed Oct 14 07:36:42 EDT 2009
Dave Angel wrote:
> def find(root):
> for pdf in os.walk(root, topdown=False):
> for file in pdf[2]:
> yield os.path.join(pdf[0],file)
>
>
At the risk of nitpicking, I think that a modicum of
tuple-unpacking would aid readability here:
<code>
for dirpath, dirnames, filenames in os.walk (root, topdown=False):
for filename in filenames:
yield os.path.join (dirpath, filename)
</code>
TJG
More information about the Python-list
mailing list