Toggle navigation
JUPYTER
FAQ
View as Code
View on GitHub
Execute on Binder
Download Notebook
tutorials
python-ipython
Notebook
An introduction to the IPython notebook
1 Before starting...
2 User interface
2.1 Main editing area
2.2 Menu
2.3 Header bar
2.4 The pager at the bottom
3 Tab completion and tooltips
4 Plotting support
5 Interactive Widgets
5.1 Plot controlled by Widgets
5.2 Factorization Example using Interactive Widgets and SimPy
6 Markdown cells can contain formatted text and code
7 Rich display: include anything a browser can show
7.1 Videos
7.2 Cloud Data Analysis and Graphing Tools
7.3 External Websites
8 Loading external codes
Python Basic Concepts
1 Why Python?
2 Python101
2.1 Two important language features:
2.2 The bricks of Python are:
2.3 Variables, as everything else, in Python are objects
2.4 Mutable / Immutable Objects
2.5 Scripts, modules and namespaces
3 Strings
4 String formatting
5 Lists
6 Slicing
7 Sets
8 Tuples
9 Dictionaries
10 Counters
11 IF - FOR - WHILE
11.1 IF
11.2 FOR - ELSE
11.3 WHILE
Python Getting Started
1 Comment your code !
2 Functions
2.1 Local Functions
2.2 External Functions
2.3 Private Methods
2.4 Anonymous Functions (lambda functions)
3 File I/O
3.1 Simple I/O
3.2 Pickle / cPickle
4 Operating System
4.1 General Info
4.2 sys — System-specific parameters and functions
4.3 os — Miscellaneous operating system interfaces
4.4 glob — Unix style pathname pattern expansion
Python Style Guide
1 PEP8
2 Syntax and Naming Conventions
2.1 Avoid using semicolons at the end of lines
2.2 Avoid having multiple statements on a single line
2.3 Indent your code block with 4 spaces
2.4 Imports: Should always be on separate lines, if refered to different modules.
2.5 Whitespace: required or not?
2.6 Naming: names in python should be chosen according to the following conventions:
3 Working with Data
3.1 Avoid using a temporary variable when swapping two variables
3.2 Use tuples to unpack data
3.3 Strings: Use join and list to create a string from a list and viceversa
3.4 Strings: Use startswith and endswith instead of string slicing to check for prefixes or suffixes.
3.5 Dictionaries: Use the default parameter of dict.get to provide default values
3.6 File IO: Use Context Managers to ensure resources are properly managed
4 Control Structures
4.1 Don't compare boolean values to True or False using ==
4.2 Avoid placing conditional branch on the same line as the colon
4.3 Comparisons to singletons like None should always be done with is or is not.
4.4 Avoid repeating variable name in compound if Statement
4.5 Use list comprehensions to create lists that are subsets of existing data
4.6 Indexes in for Loops
[4.7 range
and
xrange`](py04v01_python_style_guide.ipynb#4.7-range
-and-
xrange`)
Python More Examples
1 Working with Win32Com - Excel example
2 Sending an e-mail from a gmail account
3 Automating google search
Object Oriented Python and Exceptions
1 Understanding Objects
1.1 Creating a class
1.2 Instantiating a class
1.3 Accessing attributes
1.4 Class methods
1.5 Accessing methods
1.6 Is
init
always required?
2 Inheritance
3 Duck typing and Polymorphism
4 Legacy style classes
5 How long does a class have to be?
Object Oriented Programming in Python
1 How to define classes
1.1 Protect your abstraction
2 Inheritance
2.1 Overriding methods
3 Encapsulation
3.1 Composition
3.2 Dynamic Extension
3.2.1 Example
3.3 Polymorphism and DuckTyping
3.4 Legacy style classes
3.5 How long does a class has to be?
Integration of Python with compiled languages
1 Introduction
2 Speeding up Python code with Cython
2.1 References
3 Integrating C/C++ code into Python with Weave
3.1 References
4 Access to external libraries with ctypes
4.1 References
5 Embedding Python in C
5.1 References
Unicode
1 The World and Unicode
2 Encoding and decoding in Python 2.x
3 Implicit conversion in Python 2.x
4 Bytes Outside, Unicode Inside
Regular Expressions
1 Finding wanted words and pieces of information (in a text complexity)
2 Python easy solutions for simple problems
2.1 Some of the built-in python string functions may solve some of the easiest tasks:
2.1.1 find
2.1.2 strip, lstrip, rstrip
2.1.3 replace
2.1.4 functions for identifying the type of character
2.1.5 a slightly more complex example
2.2 The Power of Regular Expressions
2.3 Python re module