{article Examples__Python 3.4 }{title} {text} {/article}

How to execute a file within the python shell?


exec(open("./random_file.py").read())

>>> exec(open("./random_file.py").read())

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> exec(open("./random_file.py").read())
</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}