[Python-3000] Radical idea: remove built-in open (require import io)
baptiste13 at altern.org
Sun May 20 16:10:15 CEST 2007
Guido van Rossum a écrit :
> On 5/18/07, Baptiste Carvello <baptiste13 at altern.org> wrote:
>> Guido van Rossum a écrit :
>>> Do people think it would be too radical if the built-in open()
>>> function was removed altogether, requiring all code that opens files
>>> to import the io module first? This would make it easier to identify
>>> modules that engage in I/O.
>> Will someone think of the interactive users ?
> What kind of interactive use are you making of open()?
Well, mostly two things: for one, quick inspection of data files (I'm working in
physics). Sure, I can also use pylab.load with most reasonable data file
formats. But sometimes, you have a really weird format and/or you just want to
quickly read a few values. The other main use case is common sysadmin-type jobs,
>>> for line in open('records.txt'):
... print line.split(':')
Now, I was jokingly making it sound more dramatic than it really is. Of course,
I can do import io (especially with a 2-letter module name, it's not that bad),
just like I now do import shutil (or is that shutils, I never remember) when I
need to modify the filesystem. No big deal.
I just wanted to point out that any cleaning of the builtin namespace is a
benefit for programmers, but also a disadvantage for interactive users. How the
trade-off is made is yours to decide.
Thanks for caring,
More information about the Python-3000