NEWbie asks "is Python a good tool for automated file/folder generation?"
Peter Hansen
peter at engcorp.com
Mon Jun 17 21:05:55 EDT 2002
More information about the Python-list mailing list
Mon Jun 17 21:05:55 EDT 2002
- Previous message (by thread): NEWbie asks "is Python a good tool for automated file/folder generation?"
- Next message (by thread): NEWbie asks "is Python a good tool for automated file/folder generation?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark McEahern wrote: > > > I've never used Python, and I'm wondering if you, collectively, think > > that Python is a good language to do this. > > Sure. I'd recommend starting with simple things: > > Fire up Python and do this: > > >>> import os > >>> path = "c:\type your path here" > >>> print os.listdir(path) I realize this was just a pseudo-example, but I think we should point out for the pre-newbie :-) that the above has a bug. Using the backslash in a string like that can cause mysterious problems when it produces special characters by combining with the following letters as escape codes. The above string, for example, has no backslash in it, though it does have a TAB character which has somehow appeared after the "c:" and before the word "ype" ... :-) Better to learn to use raw-strings, with an "r" in front, as in path = r"c:\this is a safe path" or better yet, either forward slashes always: path = "c:/this works too". -Peter
- Previous message (by thread): NEWbie asks "is Python a good tool for automated file/folder generation?"
- Next message (by thread): NEWbie asks "is Python a good tool for automated file/folder generation?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list