Introduction To Python
Introduction To Python
Topics
What is Python? Why Python? How does it compare to other languages? Examples How to get started using Python Python for C/C++ programmers
Introduction to Python
What is Python?
Created by Guido van Rossum in 1989 Free/open scripting language:
Interpreted Dynamically typed
Both procedural and object-oriented Semantically similar to C/C++ and Perl Can easily be extended or embedded
Broad license (not GPL, but GPL compatible)
Why Python?
Free/open Has a clear, clean syntax Works as you expect Batteries Included Has lots of extensions and a strong community Highly portable Scales well Mature and stable Well documented
Introduction to Python
Compared to C++
Simplified system of object classes Does generic programming via binding rather than templates Batteries Included
Introduction to Python
Compared to TCL
Much more readable Uses TCLs TkInter system as standard GUI
Compared to Matlab:
Free/open General use Indexing is zero-based rather than horrible Has strong support for namespaces and object-oriented programming Supports scientific programming via extension modules
Introduction to Python
Pythons Design
Clean, minimal syntax: executable pseudo code Implemented in C and is generally C-like Uses indentation to delimit blocks Supports both procedural and object-oriented programming Uses a small set of powerful data types: float, int, list, tuple, dictionary (aka hash) Supports generic programming via dynamic binding rather than templating
Introduction to Python
Python isnt a systems language but its useful for nearly everything else
Introduction to Python
Introduction to Python
Introduction to Python
Introduction to Python
Introduction to Python
Introduction to Python
Which Python?
Python has always been fully backwards compatible through version 2.x Version 3.x deliberately breaks compatibility to clean up minor things Guido didnt like A tool to automatically convert 2.x code to 3.x is provided Version 2.x is still fully supported.
Version 2.6.5 is current More 2.x versions will be released
Which Distribution?
The canonical version is at python.org. ActivePython includes an IDE and a nice help system Python(x, y) at http://www.pythonxy.com is a bundle of Python 2.6 with lots of scientific and numeric extensions Others: SAGE, IronPython (.NET), Jython, Cython
Introduction to Python
Dont use const, static, etc. Dont use pointers (not needed with dynamic binding) Can change a variables type on-the-fly, as above
Introduction to Python
Introduction to Python
All class functions are virtual Override operators via special function names, e.g. use __gt__ rather than operator>
Introduction to Python
"If you have something that you don't want anyone to know, maybe you shouldn't be doing it in the first place." Eric Schmidt, CEO of Google
Summary
What is Python?
A free/open, general-use object-oriented scripting language
Why Python?
Its the Swiss Army Knife of programming languages
Final Thought
Introduction to Python