What is an alternative to execfile in Python 3?

1.3K    Asked by DanielCameron in Python , Asked on Apr 13, 2021

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

Is there an obvious alternative I'm missing?

Answered by Daniel Cameron

Use this exec(open("./filename").read()) instead of this execfile("./filename") to solve execfile python 3



Your Answer

Interviews

Parent Categories