Skip to main content
added 216 characters in body
Source Link
Paul Draper
  • 84.1k
  • 53
  • 216
  • 303

From the Python console, you can run

execfile('program.py')

where program.py is the path to your file.

EDIT:

In Python 3, you'd have to define execfile yourself before you could use it. Copy and paste the following.

def execfile(path, globals=None, locals=None):
    with open(path, "r") as file:
        exec(file.read(), globals, locals)

You specifically asked for running it from the Python prompt, but if possible, consider running it from the normal command prompt (DOS, bash, etc.) It's a little easier, and more normal.

From the Python console, you can run

execfile('program.py')

where program.py is the path to your file.

EDIT:

In Python 3, you'd have to define execfile yourself before you could use it.

def execfile(path, globals=None, locals=None):
    with open(path, "r") as file:
        exec(file.read(), globals, locals)

From the Python console, you can run

execfile('program.py')

where program.py is the path to your file.

EDIT:

In Python 3, you'd have to define execfile yourself before you could use it. Copy and paste the following.

def execfile(path, globals=None, locals=None):
    with open(path, "r") as file:
        exec(file.read(), globals, locals)

You specifically asked for running it from the Python prompt, but if possible, consider running it from the normal command prompt (DOS, bash, etc.) It's a little easier, and more normal.

Post Undeleted by Paul Draper
Post Deleted by Paul Draper
Source Link
Paul Draper
  • 84.1k
  • 53
  • 216
  • 303

From the Python console, you can run

execfile('program.py')

where program.py is the path to your file.

EDIT:

In Python 3, you'd have to define execfile yourself before you could use it.

def execfile(path, globals=None, locals=None):
    with open(path, "r") as file:
        exec(file.read(), globals, locals)