Here's a simple Python script that will do it. It's not very sophisticated, but it's easy to modify for special cases.
import os, string def Find(TargetString, DIR, Names): for Name in Names: if Name != "Search.py": try: TargetFile = DIR + "/" + Name Blob = open(TargetFile, "r").read() if Blob.find(TargetString) > -1: print TargetFile except IOError: pass return TargetString = 'telnetlib' print "\nFinding " + TargetString + "\n---------------\n" os.path.walk(".", Find, TargetString) ============================================== -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Janesh Ramakrishnan Sent: Thursday, March 30, 2006 5:57 PM To: tutor@python.org Subject: [Tutor] Searching across .Py files for a particular string/character Hi Folks, I was wondering what would be the best way to look up a string across different files in the Python interpreter (PythonWin 2.4). The find function only finds files within currently open files. If I have a folder of .py scripts and need to look up a specific keyword or string among all these files within the project folder, is there any method that you'd recommend? For eg: Visual Studio 6.0 can look for a string across numerous files indexed in a project and returns a list of files containing that specific string. Any help would be greatly appreciated. Thanks. Janesh _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor