Functions return the position of master well in python.
def myPath():
for root,dirs,files in os.walk(dir):
for fn in files:
path = os.path.join(root, fn)
return path
return path
return path
ls /home/bb/C/
a.out main.c simple_write t.c
Three positions "return" is not what I want.
I want to get result "All the files in the C"
def filesize(path):
for root, dirs, files in os.walk(PATH):
for fn in files:
path = os.path.join(root, fn)
size = os.stat(path).st_size
yield size,path
for size,path in filesize(PATH):
print size,path
but,How to achieve the above functions with the following code? How to modify it?
def find(path):
return [os.path.join(root,fn)
for root,dir,files in os.walk(dirs)
for fn in files]