What is an alternative to execfile in Python 3?

R S picture R S · Jan 12, 2009 · Viewed 288.4k times · Source

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?

Answer

Pedro Vagner picture Pedro Vagner · May 16, 2013

According to the documentation, instead of

execfile("./filename") 

Use

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

See: