ASKER
# Here is the minimal version.
import os
for root, dirs, files in os.walk('c:\\program files\\python25'):
if 'this.txt' in files:
print root
# If you want to pass the file name via the command line
import os, sys
for root, dirs, files in os.walk('c:\\program files\\python25'):
if sys.argv[1] in files:
print root
ASKER
import os # import the os module only if you find it necessary
import sys # sys.argv contains command line arguments and also the name of the script
pgm = sys.argv[0]
print pgm # not neccessarily the full path on some systems
print os.path.abspath(pgm) # this is absolutized and normalized
import os, sys
for drive in "CDE": # for example
for root, dirs, files in os.walk(drive + ":\\"):
if sys.argv[1] in files:
print root
ASKER
ASKER
Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.
TRUSTED BY