0% found this document useful (0 votes)
2 views4 pages

0. The Python Tutorial — Python 3.9.5 documentation

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

The Python Tutor al

Python s an easy to learn, powerful programm ng language. It has eff c ent h gh-level data
structures and a s mple but effect ve approach to object-or ented programm ng. Python’s elegant
syntax and dynam c typ ng, together w th ts nterpreted nature, make t an deal language for
scr pt ng and rap d appl cat on development n many areas on most platforms.

The Python nterpreter and the extens ve standard l brary are freely ava lable n source or b nary
form for all major platforms from the Python Web s te, https://www.python.org/, and may be freely
d str buted. The same s te also conta ns d str but ons of and po nters to many free th rd party
Python modules, programs and tools, and add t onal documentat on.

The Python nterpreter s eas ly extended w th new funct ons and data types mplemented n C or
C++ (or other languages callable from C). Python s also su table as an extens on language for
custom zable appl cat ons.

Th s tutor al ntroduces the reader nformally to the bas c concepts and features of the Python
language and system. It helps to have a Python nterpreter handy for hands-on exper ence, but all
examples are self-conta ned, so the tutor al can be read off-l ne as well.

For a descr pt on of standard objects and modules, see The Python Standard L brary. The Python
Language Reference g ves a more formal def n t on of the language. To wr te extens ons n C or
C++, read Extend ng and Embedd ng the Python Interpreter and Python/C API Reference Manual.
There are also several books cover ng Python n depth.

Th s tutor al does not attempt to be comprehens ve and cover every s ngle feature, or even every
commonly used feature. Instead, t ntroduces many of Python’s most noteworthy features, and w ll
g ve you a good dea of the language’s flavor and style. After read ng t, you w ll be able to read
and wr te Python modules and programs, and you w ll be ready to learn more about the var ous
Python l brary modules descr bed n The Python Standard L brary.

The Glossary s also worth go ng through.

1. Whett ng Your Appet te


2. Us ng the Python Interpreter
2.1. Invok ng the Interpreter
2.1.1. Argument Pass ng
2.1.2. Interact ve Mode
2.2. The Interpreter and Its Env ronment
2.2.1. Source Code Encod ng
3. An Informal Introduct on to Python
3.1. Us ng Python as a Calculator
3.1.1. Numbers
3.1.2. Str ngs
3.1.3. L sts
3.2. F rst Steps Towards Programm ng
4. More Control Flow Tools
4.1. if Statements
4.2. for Statements
4.3. The range() Funct on
4.4. break and continue Statements, and else Clauses on Loops
4.5. pass Statements
4.6. Def n ng Funct ons
4.7. More on Def n ng Funct ons
4.7.1. Default Argument Values
4.7.2. Keyword Arguments
4.7.3. Spec al parameters
4.7.3.1. Pos t onal-or-Keyword Arguments
4.7.3.2. Pos t onal-Only Parameters
4.7.3.3. Keyword-Only Arguments
4.7.3.4. Funct on Examples
4.7.3.5. Recap
4.7.4. Arb trary Argument L sts
4.7.5. Unpack ng Argument L sts
4.7.6. Lambda Express ons
4.7.7. Documentat on Str ngs
4.7.8. Funct on Annotat ons
4.8. Intermezzo: Cod ng Style
5. Data Structures
5.1. More on L sts
5.1.1. Us ng L sts as Stacks
5.1.2. Us ng L sts as Queues
5.1.3. L st Comprehens ons
5.1.4. Nested L st Comprehens ons
5.2. The del statement
5.3. Tuples and Sequences
5.4. Sets
5.5. D ct onar es
5.6. Loop ng Techn ques
5.7. More on Cond t ons
5.8. Compar ng Sequences and Other Types
6. Modules
6.1. More on Modules
6.1.1. Execut ng modules as scr pts
6.1.2. The Module Search Path
6.1.3. “Comp led” Python f les
6.2. Standard Modules
6.3. The dir() Funct on
6.4. Packages
6.4.1. Import ng * From a Package
6.4.2. Intra-package References
6.4.3. Packages n Mult ple D rector es
7. Input and Output
7.1. Fanc er Output Formatt ng
7.1.1. Formatted Str ng L terals
7.1.2. The Str ng format() Method
7.1.3. Manual Str ng Formatt ng
7.1.4. Old str ng formatt ng
7.2. Read ng and Wr t ng F les
7.2.1. Methods of F le Objects
7.2.2. Sav ng structured data w th json
8. Errors and Except ons
8.1. Syntax Errors
8.2. Except ons
8.3. Handl ng Except ons
8.4. Ra s ng Except ons
8.5. Except on Cha n ng
8.6. User-def ned Except ons
8.7. Def n ng Clean-up Act ons
8.8. Predef ned Clean-up Act ons
9. Classes
9.1. A Word About Names and Objects
9.2. Python Scopes and Namespaces
9.2.1. Scopes and Namespaces Example
9.3. A F rst Look at Classes
9.3.1. Class Def n t on Syntax
9.3.2. Class Objects
9.3.3. Instance Objects
9.3.4. Method Objects
9.3.5. Class and Instance Var ables
9.4. Random Remarks
9.5. Inher tance
9.5.1. Mult ple Inher tance
9.6. Pr vate Var ables
9.7. Odds and Ends
9.8. Iterators
9.9. Generators
9.10. Generator Express ons
10. Br ef Tour of the Standard L brary
10.1. Operat ng System Interface
10.2. F le W ldcards
10.3. Command L ne Arguments
10.4. Error Output Red rect on and Program Term nat on
10.5. Str ng Pattern Match ng
10.6. Mathemat cs
10.7. Internet Access
10.8. Dates and T mes
10.9. Data Compress on
10.10. Performance Measurement
10.11. Qual ty Control
10.12. Batter es Included
11. Br ef Tour of the Standard L brary — Part II
11.1. Output Formatt ng
11.2. Templat ng
11.3. Work ng w th B nary Data Record Layouts
11.4. Mult -thread ng
11.5. Logg ng
11.6. Weak References
11.7. Tools for Work ng w th L sts
11.8. Dec mal Float ng Po nt Ar thmet c
12. V rtual Env ronments and Packages
12.1. Introduct on
12.2. Creat ng V rtual Env ronments
12.3. Manag ng Packages w th p p
13. What Now?
14. Interact ve Input Ed t ng and H story Subst tut on
14.1. Tab Complet on and H story Ed t ng
14.2. Alternat ves to the Interact ve Interpreter
15. Float ng Po nt Ar thmet c: Issues and L m tat ons
15.1. Representat on Error
16. Append x
16.1. Interact ve Mode
16.1.1. Error Handl ng
16.1.2. Executable Python Scr pts
16.1.3. The Interact ve Startup F le
16.1.4. The Custom zat on Modules

You might also like