How is Python an interpreted language?

Hi,
i want to know how is python an interpreted language

1 Like

Because it’s (most of the time) used through an interpreter.

3 Likes

I have found that wikipedia is really not bad at all for answering basic computer science questions accurately. A lot of training material on the field is probably a good place to go to after wikipedia becomes too shallow. Google for Test Automation University, and start running through the python learning path there.

I think you did ask this question before Jhon. I think an important point to remember, is to understand that interpreted languages do not bind data to fixed types. Meaning they have the ability to deal with runtime interface changes and object type changes transparently.

For example in interpreted language “Late binding”, means when the interpreter sees a variable, it says, hey variable, what kind of variable are you, are you a number, or are you perhaps a function I need to call instead? Okay, I’ll do the right thing with you in that case. When you start thinking that way, scripted or interpreted is much more powerful, because the programmer can swap between versions of an object or interface without needing to recompile. And that’s because every time the interpreter sees a variable, it makes no assumptions about it’s type beforehand, even if it saw that same variable just 2 lines previously. Python and other interpreted languages then also become easier to write generalized algorithms in, that can handle data in different formats, making it a favorite for mathematicians and researchers.

3 Likes

Isn’t the characteristics described in the last two paragraphs about dynamic typing (as opposed to static typing)?

1 Like

Definitely, thanks for the correction there. The correct word is Dynamic typing. Very important to remember that Dynamic typing is not unique to script languages, but merely is a feature and a strong point of the majority of script languages. I’m actually not used to talking about types in Python, since Python treats all things as objects, and for me the word type has always had a much stricter meaning. Python code is interpreted one statement at a time, which is also why when you have errors in a script, the interpreter will only ever tell you about the first error it encounters while loading a script top-down. I guess that’s one way you can differentiate a compiled from a interpreted language, it’s not a definite line though.

From a simplistic pragmatic view python has no compile, link, build cycle. You execute python scripts and all your errors appear in real time :slight_smile:

1 Like