[Tutor] What style do you call Python programming?
Steven D'Aprano
steve at pearwood.info
Fri Dec 9 17:14:31 CET 2011
Sarma Tangirala wrote:
> The point is its a scripted language.
Define "scripted language". (Scripting language?)
> Most of what you want to do should be
> about a line. Python is derived from the idea of scripted languages wherein
> constructs like loops and functions were added for more control.
I don't understand what you mean by "should be about a line". If your idea is
that Python is an interpreter that reads the source code line by line,
interpreting then executing each one in turn, you couldn't be more wrong.
Python uses a compiler that generates byte-code, then executes it in a virtual
machine, just like (for example) Java. The CPython compiler and virtual
machine is the reference implementation; the PyPy implementation is a JIT
compiler which can approach the speed of optimized C code, and in a very few
cases, actually beat it.
If Python is a "scripting language", it is a scripting language which can
perform video processing on the fly:
http://morepypy.blogspot.com/2011/07/realtime-image-processing-in-python.html
> The main
> idea of programming in python is not essentially writing a functions but
> rather like shell scripting, one line of syntax at a time.
I can't imagine why you think that is the "main idea" for programming in
Python. Even in true scripting languages like bash, the use of functions is
strongly recommended. For anything but the simplest script, you are better off
encapsulating code into functions or classes.
Of course Python can be used to write simple scripts without functions. And
complex scripts with functions. And "glue" code to interface between libraries
written in C or Fortran. And major applications with tens or hundreds of
thousands of lines of code, dozens of modules, hundreds of classes and
functions. And everything in between.
--
Steven
More information about the Tutor
mailing list