1. Introduction

1.1. Q&A

What’s the frist programming language you learned ?

How many programming languages you are using for daily work ?

What’s your favorite programming language ?

What is Python ?
A interpreted, interactive, OO programming language.

Why do people use Python ?

Why is it called Python ?
Monty Python’s Flying Circus
What is Python good for ?
high-level, a large standard library, a wide variety of 3rd-party packages

What can I do with Python ?

Which Python should I choose ?

Notes: this tutorial restrict on 2.7 and latest 3.x of cpython

1.2. Features

  • Open source
  • Dynamic scripting language
  • OO and functional
  • Free
  • Portable
  • Powerful
  • Easy to learn and to use

1.3. Design and History

  • History
  • indentation
  • explicit self
  • no case statement
  • lambda only allows expressions
  • The Zen of Python(PEP 20)
  • Guido

1.4. Resources

  • docs
  • pypi
  • pyCon/weekly

1.5. Run programs

Try interpreter

>>> 1 + 1
2
>>> ^D or exit() or quit()

>>> dir()

>>> l = [1, 2, 3]
>>> dir(l)

>>> help(l)
>>> help(l.extend)

$ python hello.py

.pyc

  • compiled .py
  • After 3.2: __pycache__

Built-in document

$ pydoc with

$ pydoc -p 8080 # then open http://localhost:8080

1.6. Python’s Arsenal

numeric, bool, sequence, dict, text, set, binary sequence, exception, object

~250 libs: