Compiling python3 code in terminal with interpreter

6,736

What you are looking for is the -i switch. According to the manpages:

-i    When  a  script  is passed as first argument or the -c option is
      used, enter interactive mode after executing the script  or  the
      command.  It does not read the $PYTHONSTARTUP file.  This can be
      useful to inspect global variables  or  a  stack  trace  when  a
      script raises an exception.

So if your script name is name.py what you need to do is run:

python3 -i name.py
Share:
6,736

Related videos on Youtube

Oresto
Author by

Oresto

Updated on September 18, 2022

Comments

  • Oresto
    Oresto over 1 year

    When I compile my code simply with the command python3 name.py, it's being run, but then the whole story ends and I can't do anything with the compiled data.

    I want to somehow compile my program to the interpreter and have the ability to experiment with the data in that interpreter. For example, I want to use timeit(function(argument)) with the function and the argument, defined and set in my name.py program.