Is Python a Scripting Language?

Yes, you can use Python as a scripting language. Using Python you can write scripts to automate very simple tasks with just a few lines of code. At the same time considering Python just a scripting language is not accurate considering that you can use Python to create complex programs of any kind (web applications, data analysis tools, APIs and a lot more).

This is a very common question I see everywhere online…

You can consider Python a scripting and a programming language.

Confusing, right?

And that’s because Python can really do both.

What is the Difference Between a Script and a Program?

A script usually consists of few lines of codes and it solves a very specific problem.

Here are some things you can use a script for:

  • automate small tasks
  • extract info from a set of data
  • manipulation of files and directories
  • scrape data from a website

And here’s a very common scenario in which you could write a script…

One day you execute a task manually, let’s say you are reading data from a website and you are copying some of this data to a spreadsheet.

You think this is a one-off tasks but then you realise that there’s value in collecting that data every day.

That’s were a script comes handy…

…when you have a repetitive task to execute multiple times exactly in the same way.

And instead of executing it manually you write a script that does it for you in a fraction of the time.

When you run a Python script, a program called interpreter reads and analyses the code one line at the time while it’s being executed and it terminates the script when it encounters an error.

In addition, you can also use a script to glue multiple compiled programs, so you might compile multiple programs and then run them in a specific sequence using a script.

When we talk about a program we usually refer to a lot more lines of codes than in a script.

A compiled program is translated into native machine code and for this reason is generally faster than an interpreted one.

As part of the compilation process, the compiler reads and analyses the code once and reports all the errors found in the code.

The following table summarises some of the differences between a script and a program (a compiled program to be precise):

ScriptProgram
Interpreted
Standalone piece of code
Automates repetitive tasks
Can be created quickly
Ideal for managing files and directories (system tasks)
Can get hard to maintain as it grows
Can be used to run one of multiple programs
Compiled
Part of a bigger system (e.g. a webapp)
Not necessarily related to automation
Requires more development time
Not ideal for managing files and directories
Built in a modular way to be maintainable
Can be executed using a script

Does it make sense?

Conclusion

It’s very common starting using Python as a scripting language when you are learning it and writing your first code.

Why?

Because it’s easier to write scripts and it gives you a basic understanding of Python as a language, an understanding of what Python can do.

It’s a lot harder to create a complex program, using a modular approach and even using an object-oriented approach.

Python is like a bridge between scripting languages and programming languages

Codefather

A lot of these concepts are not black and white…

The main point here is to distinguish a Python script from a more complex Python application made of multiple modules.

As you have seen in this article you can consider Python a scripting language.

However, at the same time, Python is a lot more than just that.

Let me know if you have any questions 🙂

Also, are you getting started with Python?

I created a newsletter you can’t miss for you to quickly learn the basics of Python. You can join the Python Codefather newsletter for free here.

Leave a Comment