Comments requested: brief summary of Python

Brian Quinlan brian at sweetapp.com
Tue Feb 24 12:29:14 EST 2004


> For a book I am working on, I have written a brief (9 page) summary
> of Python. The intent of this is that an experienced programmer who
> did not know Python would be able to get enough information to read and
> understand Python programs. It is not meant to be a 100% complete
> summary of the language, but everything in there should be correct.

! Python is an interpreted language. 

Nope. Python is a language. The C implementation of which behaves similarly
to your description of Java i.e. Python scripts are compiled into an
intermediate format, known as bytecode, and then run through an bytecode
interpreter.

! Statements in Python are terminated by a newline

Or semicolon

! Python figures out which type a variable should be the first time it 
! is used.

No. In Python the concept of a variable is completely divorced from the
concept of type. A type is NEVER associated with a variable so no figuring
out is needed.

| i = "Hello"
| will make i a string.

Same. i is a variable, not a string.

| However, once the type of a variable is declared, it keeps that type; if
| you declare: i = "5"

Wrong for same reason, but this suggests that:

i = "5"
i = 10
i = lambda x: x * 2

wouldn't work. But it will.

> Multiple variables can be assigned at once, as in two, three = 2, 3

This should not be discussed here as it is not a new concept. This is just
sequence unpacking and works with any sequence type.

! Multi-line strings are often included in Python code without being
! assigned to anything (which means they have no semantic relevance): it's a
! way to include multi-line comments in the code.

They do have semantic significance if they start at the beginning of a
module, function or method; they get assign to that object's __doc__
attribute.

These specific errors aside, I think that there is an overall tone problem
with this description. I can't really qualify it but maybe the problem is
that you are comparing Python to a statically-typed language throughout.
Maybe you should make the first part more conceptual if you are targeting C
programmers and worry about syntax in the last couple of pages?

Cheers,
Brian





More information about the Python-list mailing list