script python

Qu'est qu'un script?

Extraite de wikipedia ( :
"A scripting language or script language is a programming language that supports scripts, programs written for a special run-time environment that can interpret (rather than compile) and automate the execution of tasks which could alternatively be executed one-by-one by a human operator. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), and embedded systems. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language. Scripting languages are also sometimes referred to as very high-level programming languages, as they operate at a high level of abstraction.

The term "scripting language" is also used loosely to refer to dynamic high-level general-purpose language, such as Perl,[1]Tcl, and Python,[2] with the term "script" often used for small programs (up to a few thousand lines of code) in such languages, or in domain-specific languages such as the text-processing languages sed and AWK. Some of these languages were originally developed for use within a particular environment, and later developed into portable domain-specific or general-purpose languages. Conversely, many general-purpose languages have dialects that are used as scripting languages. This article discusses scripting languages in the narrow sense of languages for a specific environment; dynamic, general-purpose, and high-level languages are discussed at those articles."

Un script, c'est un programme qui est exécuté (normalement par un interpréteur) qui exécute directement le programme, instruction par instruction, sans passer par une compilation, c'est à dire une traduction du programme dans une langage de plus bas niveau, voir un langage machine.

Script Python - Module Python

C'est tout simplement un programme Python, écrit donc en Python, mis dans un module Python. Et un modulme Python, c'est un fichier avec l'extension py.

Comment lancer l'exécution d'un module Python? De trois façons :

  • soit en lançant l'exécution du module python via une commande python, bpython, ...
>>>python3 <arguments>
  • soit en lançant le script Python dans une script système, Unix par exemple
>>>import module
>>>from module import f1, f2

Pour vous aider à comprendre le lancement d'un script, lire les entrées module, _main_ et import.

» Glossaire du langage python