On 10 June 2014 12:23, Paul Sokolovsky <pmis...@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()). I'm > sure that's not going to bother a lot of people - after all, the > easiest way to execute a Python file is to drop back to shell and > restart python with file name, using all wonders of tab completion. But > now imagine that Python interpreter runs on bare hardware, and its REPL > is the only shell. That's exactly what we have with MicroPython's > Cortex-M port. But it's not really MicroPython-specific, there's > CPython port to baremetal either - http://www.pycorn.org/ .
https://docs.python.org/3/library/runpy.html#runpy.run_path import runpy file_globals = runpy.run_path("file.py") The standard implementation of run_path reads the whole file into memory, but MicroPython would be free to optimise that and do statement by statement execution instead (while that will pose some challenges in terms of handling encoding cookies, future imports, etc correctly, it's certainly feasible). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ 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