دنبال کننده ها

۱۳۹۶ اسفند ۱۳, یکشنبه

How to name variable correctly to avoid warning like "Shadows name from outer scope" in Python

[ad_1]



I use PyCharm for my python program, and I wrote codes below:



def get_files_name():
root_dir = "/Volumes/NO NAME/"
for root, ds, fs in os.walk(root_dir):
for f in fs:
print(os.path.join(root_dir, f))


get_files_name()
for root, ds, fs in os.walk(other_dir):
pass


So I get a Warning text like "Shadows name 'ds' from outer scope".
I know the effect of scope, but I still want to use the same code format like "for root, ds, fs in ...." at inner or outer of scope.



I have searched PEP8, however, I still don't know how to name variable in function normatively.



Could you give me some suggestion?




[ad_2]

لینک منبع