Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

How can I execute a Python script file with another script in Python 3?

Asked by David Edmunds Jul 22, 2024 773 views 1 answer
Share

About this question

 I am currently engaged as a software developer and I am currently working on a particular project that can implement a series of Python scripts that would process data files. My project was initially developed by using Python 2, where I frequently used the execfile function to run the other script. Now I am trying to upgrade my particular project to Python 3. 

In one of my main scripts, I have the following code which can work perfectly in Python 2:

Execfile(‘script_to_run.py’)

Why is this particular line of code not working in Python 3? How can I achieve the same functionality in Python 3? 

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.