Search code examples
pythonpython-3.x

What is an alternative to execfile in Python 3?


It seems they canceled in Python 3 all the easy ways to quickly load a script by removing execfile().

Is there an obvious alternative I'm missing?


Solution

  • According to the documentation, instead of

    execfile("./filename") 
    

    Use

    exec(open("./filename").read())
    

    See: