[Python-Dev] Criticism of execfile() removal in Python3 (original) (raw)

Chris Barker chris.barker at noaa.gov
Mon Jun 16 19:40:03 CEST 2014


On Sat, Jun 14, 2014 at 1:11 PM, Paul Sokolovsky <pmiscml at gmail.com> wrote:

> > 1. It hampers interactive mode - instead of short and easy to type > > execfile("file.py") one needs to use exec(open("file.py").read()).

> If the amount of typing is the problem, that's easy to solve: > > # do this once > def execfile(name): > exec(open("file.py").read())

FWIW, when I started using python (15?) years ago -- the first thing I looked for was a way to "just run a file", at the interactive prompt, like I had in MATLAB. I found and used execfile().

However, it wasn't long before I discovered that excecfile() was really kind of a pain, you've got namespaces, and all sorts of stuff that made it often not work like I wanted, and was a pain to type. I stopped using it all together

More recently, I discovered iPython and its "run" function -- very nice, it does the obvious stuff for you the way you'd expect.

My conclusions:

  1. runfile() is not really very usefull, it's fine to hve removed it.

  2. the built-in interactive python interpreter is really pretty lame. If you want a good interactive experience, you need something more anyway (iPython, for instance) -- putting execfile() back is only one tiny improvement that's not worth it.

So if this is about micropython -- I think it would serve the project very well to have a micropython-specific interactive mode. iPython is fabulous, but though I imagine too heavy weight. But perhaps you could borrow some things from it -- like "run" , for example.

-Chris

--

Christopher Barker, Ph.D. Oceanographer

Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140616/2e0d06e0/attachment.html>



More information about the Python-Dev mailing list