[issue3177] Add shutil.open
Éric Araujo
report at bugs.python.org
Mon Apr 23 15:58:39 CEST 2012
Éric Araujo <merwok at netwok.org> added the comment:
Thanks for relaunching this!
> I'm not sure I understand why this was moved to shutil.open. It seems appropriate to try to accomplish what
> os.startfile() does in a cross-platform way. Don't many of the other os.* calls do this--check os.name and
> then "do the right thing".
They don’t. The os module is a thin wrapper on top of system functions. Cross-platform compat is not achieved with os.name checks but with platform-specific code in the C files. As Windows provides a call named startfile, it is exposed. When we want to provide a higher-level API on top of system calls, we use other modules such as shutil.
> fix minor shutil.disk_usage() doctext typo
Would you report this on another bug report or simply with a mail to the docs at python.org mailing list? Thanks.
> Name changed from shutil.open to shutil.launch due to namespace conflict with open() builtin within the shutil
> module and for users that do from shutil import *
I don’t think these are good arguments. A lot of modules expose a function named open: tarfile, codecs, tokenize... Python has namespaces, let’s use them. The argument about import * is not strong either in my opinion, because all our docs recommend against this idiom.
One argument against open is that the other open functions I mention above return a file object, like the builtin open. With this in mind I agree that a better name should be found. I dislike launch though because it brings to my mind the idea of running/executing a program, not opening it in the appropriate program.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3177>
_______________________________________
More information about the Python-bugs-list
mailing list