This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients larry
Date 2012-04-19.23:52:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334879559.02.0.192331437376.issue14626@psf.upfronthosting.co.za>
In-reply-to
Content
There are some functions in the os module that do much the same thing but differ only in minor ways, like

* whether or not they follow symbolic links (stat vs lstat)
* taking an extra "dir_fd" parameter (chmod vs fchmodat(3.3))

It would be better if we consolidated these variations into one function which took keyword-only parameters that allow access to the alternate functionality.

Here is a sample of the new possible function signatures, as originally proposed by Serhiy Storchaka:

access(path, mode, *, followlinks=True, dirfd=None, eaccess=False)
chmod(path, mode, *, followlinks=True, dirfd=None)
chown(path, uid, gid, *, followlinks=True, dirfd=None)
link(srcpath, dstpath, *, followlinks=True, srcdirfd=None, dstdirfd=None)
mkdir(path, mode=0o777, *, dirfd=None)
mknod(path, mode=0o600, device=0, *, dirfd=None)
open(path, flag, mode=0o777, *, dirfd=None)
readlink(path, *, dirfd=None)
rename(oldpath, newpath, *, olddirfd=None, newdirfd=None)
stat(path, *, followlinks=True, dirfd=None)
symlink(src, dst, *, dirfd=None)
unlink(path, *, removedir=False, dirfd=None)
utimes(path[, (atime, mtime)], *, ns=False, dirfd=None)
mkfifoat(path, mode=0o666, *, followlinks=True, dirfd=None)

My opinion about naming: PEP 8 suggests underscores to separate words in non-class identifiers.  So I'd spell those "dir_fd", "src_dir_fd" (etc), "remove_dir", and "follow_symlinks".

(While thinking about this, I remembered the infrequently-cited maxim "no boolean parameters".  But that's more a guideline than a rule, and it tends to be a complaint about how the meaning of the parameter is unclear at a call site.  As these will be keyword-only parameters I think their meanings will be perfectly clear, so I shan't worry about it.)
History
Date User Action Args
2012-04-19 23:52:39larrysetrecipients: + larry
2012-04-19 23:52:39larrysetmessageid: <1334879559.02.0.192331437376.issue14626@psf.upfronthosting.co.za>
2012-04-19 23:52:38larrylinkissue14626 messages
2012-04-19 23:52:38larrycreate