I very new to python. I am trying to find all python files that hav the string "DATASOURCE" inside them and to print the path name of the files. I'm using this code:
import os,glob
os.chdir(r"G:\PROJECTS\menofim_3_5\gis")
for file in glob.glob('*.py'):
with open(file) as f:
contents = f.read()
if 'DATASOURCE' in contents:
print file
I only get this result:
>>>
findAndReplaceWorkspacePaths-dwg.py
Remove FGB by dataSource excluding specific mxd.py
SelectLayerByLocation2.py
SelectLayerByLocation3.py
>>>
I have succeeded in printing the file name, but I don't know how to print the path name of the files.
with