|  | ||
| 
 | 
| ----- Original Message ----- From: Miles Bader Date: 5/28/2009 10:58 PM The library was originally a Lua wrapper module called 'iox' on top of the Windows shlwapi.dll. All of those APIs used the term "path", which could refer to a directory name or filename. Therefore, I'm not sure referring to just a filename is sufficient. Python has a library for pathname manipulation called os.path, too.Joshua Jensen <jjensen@workspacewhiz.com> writes:* List of os.path.* functionsThe term "path" seems pretty unix-centric; perhaps simply "filename" would be better? I've always found a need to convert between the two. Windows, for instance, accepts both forward slash and backslash filenames.Also, the "slash" and "backslash" methods seem very kludgey; I don't think users of (more or less) portable filename library should really be thinking at that level. This is certainly an interesting idea. As I stated above, many of the names are derived from the shlwapi calls.I think it's often a mistake to use terms that imply a side-effect, like "make..." or "remove...". It might be better to instead use terminology that makes it clear that they return the changed filename e.g. "as_..." or "without_...".. e.g.: os.filename.with_extension(filename, extension) os.filename.as_absolute(filename) os.filename.without_directory(filename) os.filename.without_extension(filename) os.filename.without_filename(filename) The os.path functions work on Windows, Mac OS X, and Unix platforms. Forward slashes can be used as directory separators on all. What common platforms did you have in mind? I guess I find this more confusing. I will agree that append() and combine() (or in Python's, join()) are questionable names, although both are modeled on the Win32 APIs PathAppend() and PathCombine(), for better or worse.Maybe something like "os.filename.in_directory(filename,directory)", [basically, append filename to directory, unless filename is absolute, in which case it just uses filename]? What makes the most sense here? If I'm building a command line, I can do: myExecutable = '/dirA/dir with spaces/dirB/myexe' print(os.path.escape(myExecutable)) -- Unix: /dirA/dir\ with\ spaces/dirB/myexe -- Windows: "dirA/dir with spaces/dirB/myexe" Thanks for the valued feedback. In particular, I like the as_, with_, and without_ ideas. Josh |