[Tutor] Thanks guys!
Ray Leggett
rlegge@tc3net.com
Fri, 18 Oct 2002 14:10:26 -0400
Thanks everybody who responded to my earlier post. Between the various
suggestions I was able to figure out what I was doing wrong a lot faster
than if I had been doing this by myself. For the curious, here is the
finished script: (btw, outlook messes up the formatting!)
---------------------------------------------------------
#!/usr/bin/python
"scans a python module and lists all classes and functions"
import sys
import re
ModuleToScan = sys.argv[1]
ScanClass = re.compile('class')
ScanDef = re.compile('def')
def ScanModule(ModuleToScan):
fp = open(ModuleToScan)
source = fp.readlines()
for line in source:
if ScanClass.search(line):
print line
if ScanDef.search(line):
print line
fp.close()
return
ScanModule(ModuleToScan)