Hello, On Tue, 10 Jun 2014 13:03:03 +1000 Steven D'Aprano <st...@pearwood.info> wrote:
> On Tue, Jun 10, 2014 at 05:23:12AM +0300, Paul Sokolovsky wrote: > > > execfile() builtin function was removed in 3.0. This brings few > > problems: > > > > 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()) So, you here propose to workaround removal of core language feature either a) on end user side, or b) on "system integrator" side. But such solution is based on big number of assumptions, like: user wants to workaround that at all (hint: they don't, they just want to use it); you say "do this once", but actually it's "do it in each interactive session again and again", and user may not have knowledge to "do it once" instead; that if system integrator does that, the the function is called "execfile": if system integrator didn't have enough Python experience, and read only Python3 spec, they might call it something else, and yet users with a bit of Python experience will expect it be called exactly "execfile" and not anything else. > > Another possibility is: > > os.system("python file.py") > > > > 2. Ok, assuming that exec(open().read()) idiom is still a way to go, > > there's a problem - it requires to load entire file to memory. But > > there can be not enough memory. Consider 1Mb file with 900Kb > > comments (autogenerated, for example). execfile() could easily > > parse it, using small buffer. But exec() requires to slurp entire > > file into memory, and 1Mb is much more than heap sizes that we > > target. > > There's nothing stopping alternative implementations having their own > implementation-specific standard library modules. And here you propose to workaround it on particular implementation's level. But in my original mail, in excerpt that you removed, I kindly asked to skip obvious suggestions (like that particular implementation can do anything it wants). I don't see how working around the issue on user, particular distribution, or particular implementation level help *Python* language in general, and *Python community* in general. So, any bright ideas how to workaround the issue of execfile() removal on *language level*? [] > So you could do this: > > from upy import execfile > execfile("file.py") > > So long as you make it clear that this is a platform specific module, > and don't advertise it as a language feature, I see no reason why you > cannot do that. The case we discuss is clearly different. It's not about "platform specific module", it's about functionality which was in Python all the time, and was suddenly removed in Python3, for not fully clear, or alternatively, not severe enough, reasons. If some implementation is to re-add it, the description like above seems the most truthful way to represent that function. -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com