Updated: Sep 2, 2020
In an informal sense, in Python we do things with stuff. “Things” take the form of operations like addition and concatenation, and “stuff” refers to the objects on which we perform those operations. In this article , my focus is on - where do these sit in hierarchy and some conceptual understanding of what these are, and once we understand this, we move to focusing on that stuff, and the things our programs can do with it, but
Somewhat more formally, in Python, data takes the form of objects—either built-in objects that Python provides, or objects a user creates using Python classes or external language tools such as C extension libraries.
Objects are essentially just pieces of memory, with values and sets of associated operations. Everything is an object in a Python script. Even simple numbers qualify, with values (e.g., 99), and supported operations (addition, subtraction, and so on).
let’s first establish a clear picture of how this "stuff" is organized in python. This would help you understand and start using some python jargon.
Python programs can be decomposed into modules, statements, expressions, and objects, as follows:
Programs are composed of modules.
Modules contain statements.
Statements contain expressions.
Expressions create and process objects.
Let me quickly explain some of the jargon in plain English-
Modules are simply text files containing Python statements. You can ask the Python interpreter to execute the statements in such a file any number of times, and in a variety of ways—by system command lines, by file icon clicks, by options in IDE of your choice like "jupyter notebooks" , and more. Regardless of how it is
run, Python executes all the code in a module file from top to bottom each time you run the file.
Terminology around this can vary somewhat. For instance, module files are often referred to as programs in Python—that is, a program is considered to be a series of precoded statements stored in a file for repeated execution. Module are also sometimes called scripts. All of them mean same.
A statement is an instruction that the Python interpreter can execute. example print and assignment. When you type a statement on the command line, Python executes it and displays the result, if there is one. The result of a print statement is a value. Assignment statements don't produce a result.
A script usually contains a sequence of statements. If there is more than one statement, the results appear one at a time as the statements execute.
An expression is a combination of values, variables, and operators. If you type an expression on the command line, the interpreter evaluates it and displays the result . Ex when you type 1+1 - python interpreter compiles the expression into byte code and sends it to a python virtual machine which throws back "2" as the response. I have written in detail about how python does it in my previous article.
Operators are special symbols that represent