Run python module from console
Rhodri James
rhodri at kynesim.co.uk
Tue Sep 5 12:46:29 EDT 2017
On 05/09/17 17:11, Stefan Ram wrote:
> Ned Batchelder <ned at nedbatchelder.com> writes:
>>> exec( compile( open( 'myscr.py', 'rb' ).read(), 'myscr.py', 'exec' ))
>>> . This looks quite complicated, but there are rumors
>>> that Python 4 might have a »execfile« function, and
>>> one then will be able to write:
>>> execfile( 'myscr.py' )
>> It's better to not start rumors about fictitious Python versions.
>
> That was an attempt to make a kind of joke.
>
> The background is:
>
> Python 2 has »execfile«, but not Python 3.
>
> Another background is:
>
> We recently had this discussion, where Steve wrote:
>
> |there should be a standard solution, instead of having to
> |re-invent the wheel over and over again. Even when the wheel
> |is only two or three lines.
The difference is that inventing this particular wheel is almost always
a mistake.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-list
mailing list