Hello,

I'm going through an online tutorial for Jython (www.jython.org). I can't find 
a place to ask a question on that site so I thought I'd try here. I believe the 
code is supposed to traverse a directory, identifying file types. The script is 
failing with the following message:

  File "<string>", line None
SyntaxError: Non-ASCII character in file 
'H:\workspace\test\src\root\nested\example.py', but no encoding declared; see 
http://www.python.org/peps/pep-0263.html for details

Thank you,
Shawn



import os, sys 
from stat import *

def walktree(top, callback):
    '''recursively descend the directory tree rooted at top,
    calling the callback function for each regular file'''
    for f in os.listdir(top):
        pathname = os.path.join(top, f) 
        mode = os.stat(pathname)[ST_MODE] 
        if S_ISDIR(mode):
            # It's a directory, recurse into it 
            walktree(pathname, callback)
        elif S_ISREG(mode):
            # It's a file, call the callback function 
            callback(pathname)
        else:
            # Unknown file type, print a message 
            print 'Skipping %s' % pathname

def visitfile(file):
    print 'visiting', file

if __name__ == '__main__':
    walktree(sys.argv[1], visitfile)


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to