^^Python syntax.

Style guide: PEP8  python/dev/pep-0008

Python BNF.

Lexical analysis reference/lexical_analysis

l'analisi del lessico, per individuare le parole, in gergo "tokens"

physical line
sequence of characters terminated by an end-of-line sequence:
- Unix  ASCII LF (linefeed)
- Windows  ASCII sequence CR LF (carriage return followed by linefeed)
End of input also serves as terminator.
logical line
1 phys line, or more physical lines following the explicit or implicit line joining rules.
valid characters for identifiers
A-Z a-z  uppercase and lowercase letters
0-9 not as first character
_  underscore

Multiline structure non esiste.

Esiste la "stringa su piu' linee", ognuna che termina col simbolo "\".

Non esiste multiline comment.

Multiline expression. Implicitly continued lines.

can be split over more than one physical line without using backslashes.

es:

month_names = ['Januari', 'Februari', 'Maart',      # These are the
               'April',   'Mei',      'Juni',       # Dutch names
               'Juli',    'Augustus', 'September',  # for the months
               'Oktober', 'November', 'December']   # of the year

Implicitly continued lines can carry comments.

Python vs C >>>

multi-line strings are often used as a replacement for multi-line comment

code blocks are denoted by

    : a colon followed by

       indentation

for i in range(10):
    print(i)    # indentation indicates code block

Import. Private names.

nome privato 1 solo underscore, es: _nome

  1. import module                      import all names, anche quelli che iniziano con 1 _
  2. from module import *           import only non private
  3. from module import name     better to be explicit when importing names from modules,
                                                 rather than importing them all with a *

python/tutorial/modules#importing-from-a-package

Recognized escape sequences

\a  ASCII Bell (BEL)  print("\a") suona effettivamente il campanello
\b  ASCII Backspace (BS)
\f  ASCII Formfeed (FF)
\n  ASCII Linefeed (LF)
\r  ASCII Carriage Return (CR)
\t  ASCII Horizontal Tab (TAB)
\xhh  Character with hex value hh

 

 

Talk

code blocks are denoted by