Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way.
def convertPath(path): """ Given a path with backslashes, return that path with forward slashes. By Steven D'Aprano 07/31/2011 on Tutor list >>> path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' >>> convertPath(path) 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' """ import os.path separator = os.path.sep if separator != '/': path = path.replace(os.path.sep, '/') return path >>> from mycalc import convertPath Traceback (most recent call last): File "<string>", line 36, in <fragment> Syntax Error: """: c:\Python32\lib\site-packages\mycalc.py, line 36-1 >>> What solved the problem and what didn't: This doesn't work: def convertPath(path): """ Given a path with backslashes, return that path with forward slashes. By Steven D'Aprano 07/31/2011 on Tutor list >>> path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' >>> convertPath(path) #'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' """ import os.path separator = os.path.sep if separator != '/': path = path.replace(os.path.sep, '/') return path Nor this: def convertPath(path): """ Given a path with backslashes, return that path with forward slashes. By Steven D'Aprano 07/31/2011 on Tutor list #>>> path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' #>>> convertPath(path) #'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' """ import os.path separator = os.path.sep if separator != '/': path = path.replace(os.path.sep, '/') return path But this does: def convertPath(path): """ Given a path with backslashes, return that path with forward slashes. By Steven D'Aprano 07/31/2011 on Tutor list """ #>>> path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf' #>>> convertPath(path) #'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' import os.path separator = os.path.sep if separator != '/': path = path.replace(os.path.sep, '/') return path Thanks, Dick Moores _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor