[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Status of lposix?
- From: Miles Bader <miles@...>
- Date: Fri, 29 May 2009 13:58:26 +0900
Joshua Jensen <email@example.com> writes:
> * os.path.add_extension(path, extension): Adds extension to the end of
> path even if one already exists.
> * os.path.add_slash(path): Adds a slash to the end of path if it doesn't
> already exist.
> * os.path.make_absolute(path): Converts path into an absolute path,
> simplifying the path as necessary.
> * os.path.make_backslash(path): Convert any forward slashes in path to
> * os.path.make_slash(path): Convert any backslashes in path to slashes.
> * os.path.remove_directory(path): Removes the directory component from path.
> * os.path.remove_extension(path): Removes the extension component from path.
> * os.path.remove_filename(path): Removes the filename component from path.
> * os.path.remove_slash(path): Removes the trailing slash from path.
> * os.path.replace_extension(path, extension): Replaces the extension of
> path with the new one specified in extension.
The term "path" seems pretty unix-centric; perhaps simply "filename"
would be better?
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.
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.path.append(leftPath, rightPath): Appends leftPath and rightPath
> together, adding a slash between the two path components. If rightPath
> is an absolute path, it is not appended to leftPath and is returned
> * os.path.combine(leftPath, rightPath): Combines leftPath and rightPath,
> adding a slash between the two path components and simplifying the path
> by collapsing . and .. directories. If rightPath is an absolute path, it
> is not appended to leftPath and is returned directly.
These seem slightly confusing, as they sort of refer to the physical
composition of the filename, rather than the abstract operation that's
happening (making a _truly_ portable filename library is pretty hard,
but I think it's good to try and at least operate at a slightly higher
level of abstraction than talking about slashes etc).
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]?
> * os.path.escape(path): Properly escapes and quotes path, if needed.
There are many escape syntaxes, and which one to use depends on the
context; this method seems out of place.
Barometer, n. An ingenious instrument which indicates what kind of weather we