Movatterモバイル変換


[0]ホーム

URL:


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

Chris Barkerchris.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 Ilooked for was a way to "just run a file", at the interactive prompt, likeI had in MATLAB. I found and used execfile().However, it wasn't long before I discovered that excecfile() was reallykind of a pain, you've got namespaces, and all sorts of stuff that made itoften not work like I wanted, and was a pain to type. I stopped using itall togetherMore recently, I discovered iPython and its "run" function -- very nice, itdoes 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. Ifyou want a good interactive experience, you need something more anyway(iPython, for instance) -- putting execfile() back is only one tinyimprovement that's not worth it.So if this is about micropython -- I think it would serve the project verywell to have a micropython-specific interactive mode. iPython is fabulous,but though I imagine too heavy weight. But perhaps you could borrow somethings from it -- like "run" , for example.-Chris-- Christopher Barker, Ph.D.OceanographerEmergency Response DivisionNOAA/NOS/OR&R            (206) 526-6959   voice7600 Sand Point Way NE   (206) 526-6329   faxSeattle, WA  98115       (206) 526-6317   main receptionChris.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-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp