'Is there any difference in the way Python code is executed when run from REPL vs a script in the command line?

I was watching this video, How Do You Read a Python Traceback? and they mention that the traceback you receive will be slightly different depending on whether you are executing your code in the command line (Fig. 1) vs in the REPL (Fig. 2). With the former, the executed lines of code are displayed in the traceback, whereas they are not in the later. What is the reason for this difference? Is there any difference in the way Python code is executed when run from REPL vs a script in the command line? Is the Python code compiled in both cases to bytecode?

def greet(someone):
    print('Hello', + someon)
    
greet('Chad')

enter image description here

Figure 1. Video example of code executed from command line displays executed lines of code

enter image description here Figure 2. Video example of code executed from REPL does not display executed lines of code

Further confounding is that when executed from my Spyder IDE (which I would assume is an example of REPL capability), it unexpectedly mimics that of the command line output (Fig. 3).

enter image description here Figure 3. My output from Spyder

Finally, when run from Bash on my computer it displays the additional text: "Did you mean: 'someone'?". enter image description here Figure 4. My output from Bash



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source