On Sun, Nov 29, 2009 at 20:14, Terry Reedy <tjre...@udel.edu> wrote: > J wrote: >> >> Ok... so I've been re-teaching myself python, as it's been several >> years since I last really used it. And in the midst of this, my >> contracting company came up to me on Friday and asked if I'd be >> interested in filling a last minute vacancy in this: >> >> http://www.otg-nc.com/python-bootcamp
> The list of topics seems to cover basic + intermediate issues. > If you do go, perhaps you could review it here. > Same for people who have attended other Python training courses, of course. The last day is tomorrow, so I'll actually try and write something real then... I just wanted to say that this has been a pretty good class. Really good, compared to others I've taken (in college and so forth)... Anyway, just thought I'd share this: The difference between me (learning a new language) and the guy teaching (who knows it inside and out) My code: import os startDir = '/home/student/testdirectory' #raw_input("Enter starting location: ") searchList=['html','py','jpg'] filenames=[] report={} try: fhtml=open('HTMLFiles','w') fpy=open('PYFiles','w') fjpg=open('JPGFiles','w') except: assert 0, 'Unable to open file' for root, dirs, files in os.walk(startDir): filenames += [os.path.normcase(os.path.join(root,f)) for f in files if f[f.rfind('.')+1:] in searchList] for file in filenames: ext=file.split('.')[1] if report.has_key(ext): report[ext].extend([file]) else: report.update({ext:[file]}) for k,v in report.iteritems(): if k == 'html': for item in v: fhtml.write("%s\n" % item) if k == 'py': for item in v: fpy.write("%s\n" % item) if k == 'jpg': for item in v: fjpg.write("%s\n" % item) His code: import os def FindFiles(base_dir="/", exten=[]): results={} # Initialize results dictionary with blank arrays for l in exten: results[l]=[] for root, dirs, files in os.walk(base_dir): for e in exten: results[e] += [os.path.join(root,fn) for fn in files if fn.endswith(e)] return results files=FindFiles('C:/Python26',['exe','html']) for (exten, list) in files.iteritems(): try: f=open('extensions-%s.txt' % exten,'w') f.write('\n'.join(list)) except: assert 0, 'Unable to create output file extensions-%s.txt.' % exten Different thought processes, plus experience makes a difference too... That and while I have an educational background in programming, the only programming I've been able to do in my professional (read daily) life is BASH... I think it shows. Cheers, Jeff -- Ted Turner - "Sports is like a war without the killing." - http://www.brainyquote.com/quotes/authors/t/ted_turner.html -- http://mail.python.org/mailman/listinfo/python-list