Python Fundamentals
Welcome
Austin Bingham Robert Smallshire
@austin_bingham @robsmallshire
austin@sixty-north.com rob@sixty-north.com
Presenter
Duck typing
Duck typing
Lists
Duck typing Comprehensions
Lists
Duck typing Comprehensions
Lists
Classes
Duck typing Comprehensions
Lists
Standard library Classes
Duck typing Comprehensions
Lists Modules
Standard library Classes
Duck typing Comprehensions
Lists Modules
Standard library Classes
REPL
Duck typing Comprehensions
Lists Modules
Resource
management
Standard library Classes
REPL
Duck typing Comprehensions
Lists Modules
Resource Exceptions
management
Standard library Classes
REPL
Duck typing Comprehensions
Lists Modules
Packaging
Resource Exceptions
management
Standard library Classes
REPL
Duck typing Comprehensions
Lists Modules
Packaging
Resource Exceptions
management
Standard library Classes
Iteration
REPL
Powerful
Powerful
def fetch_words(url):
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
story_words.append(word)
return story_words
Powerful
def fetch_words(url):
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
Powerful
story_words.append(word)
return story_words
Persistence
Math
Operating System
Cryptography
Concurrency
def fetch_words(url):
Web Protocols
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
Powerful
story_words.append(word)
return story_words
Persistence
Math
Operating System
Cryptography
Concurrency
Web Protocols
def fetch_words(url):
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
Powerful
story_words.append(word)
return story_words
Persistence
Web Frameworks Math
Scientific Computing
Operating System
Image Processing
Cryptography
DatabasesConcurrency
Web Protocols
Build Systems
Documentation
def fetch_words(url):
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
Powerful
story_words.append(word)
return story_words
Web Frameworks Persistence
Scientific Computing Math
Image Processing Operating System
Databases Cryptography
Build Systems Concurrency
Documentation
Web Protocols
def fetch_words(url):
"""Fetch a list of words from a URL."""
with urlopen(url) as story:
story_words = []
for line in story:
line_words = line.decode('utf8').split()
for word in line_words:
Powerful
story_words.append(word)
return story_words
Open Source
Popular
Open Source
Accessible
Open Source Popular
Accessible
Everywhere
Open Source Popular
Accessible Everywhere
Open Source Popular
Course Overview
Structure
•10 modules
• In order
• Language features
• Libraries
• Idiomatic usage
• Example-driven
Course Overview
Structure Outcome
•10 modules • Language essentials
• In order • Library development
• Language features • Third-party packages
• Libraries • Delivering code
• Idiomatic usage
• Example-driven
Course Overview: Modules
Course Overview: Modules
1. Getting Started
Course Overview: Modules
1. Getting Started
2. Strings and Collections
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
6. Handling Exceptions
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
6. Handling Exceptions
7. Comprehensions, Iterables, and Generators
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
6. Handling Exceptions
7. Comprehensions, Iterables, and Generators
8. Defining New Types with Classes
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
6. Handling Exceptions
7. Comprehensions, Iterables, and Generators
8. Defining New Types with Classes
9. Files and Resource Management
Course Overview: Modules
1. Getting Started
2. Strings and Collections
3. Modularity
4. Built-in Types and the Object Model
5. Collection Types
6. Handling Exceptions
7. Comprehensions, Iterables, and Generators
8. Defining New Types with Classes
9. Files and Resource Management
10. Shipping Working and Maintainable Code
What is Python?
What is Python?
source: CIA World Factbook
What is Python?
source: CIA World Factbook
What is Python?
source: CIA World Factbook
What is Python?
Python Software Foundation
source: CIA World Factbook
Python is general
purpose
Who is using Python?
Who is using Python?
Google
Who is using Python?
Google
Quora
Who is using Python?
Google
Reddit
Quora
Who is using Python?
Google
Reddit
Blender
Quora
Who is using Python?
Google
Reddit
YouTube Blender
Quora
Who is using Python?
Google
CERN
Reddit
YouTube Blender
Quora
Who is using Python?
ESRI
Google
CERN
Reddit
YouTube Blender
Quora
Who is using Python?
ESRI Bitly
Google
CERN
Reddit
YouTube Blender
Quora
Who is using Python?
ESRI Bitly
Google
CERN
Reddit
YouTube Blender
Quora
Dropbox
Who is using Python?
SurveyMonkey
ESRI Bitly
Google
CERN
Reddit
YouTube Blender
Quora
Dropbox
Who is using Python?
SurveyMonkey
ESRI Bitly
Google
CERN
Industrial Lights and Magic Reddit
YouTube Blender
Quora
Dropbox
Who is using Python?
SurveyMonkey
ESRI Bitly
Google
CERN
Industrial Lights and Magic Reddit
YouTube Blender
OpenStack
Quora
Dropbox
Who is using Python?
SurveyMonkey
ESRI Bitly
Google
CERN
European Space Agency
Industrial Lights and Magic Reddit
YouTube Blender
OpenStack
Quora
Dropbox
Python is interpreted
Python is clear, readable,
and expressive
Python Implementations
CPython Written in C
Python Implementations
Java
Python Implementations
Java
IronPython .NET
Python Implementations
Java
IronPython .NET
RPython
Python 2 vs. Python 3
2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
Python 2
2.4 2.5 2.6 2.7
Python 3
3.0 3.1 3.2 3.3 3.4
Batteries Included
Python Standard Library
Python Standard Library
string
Python Standard Library
string
difflib
Python Standard Library
string
difflib
textwrap
Python Standard Library
string
difflib
textwrap
struct
Python Standard Library
string
difflib
textwrap
struct
codecs
Python Standard Library
string
difflib
textwrap
struct
codecs
datetime
Python Standard Library
string
difflib
textwrap
struct
codecs
datetime
heapq
Python Standard Library
string
difflib
textwrap
struct
codecs
datetime
heapq
weakref
Python Standard Library
string
difflib
textwrap
struct
codecs
datetime
heapq
weakref
copy
Python Standard Library
string
difflib
textwrap
struct
codecs
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib
textwrap
struct
codecs
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap
struct
codecs
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct
codecs
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint
Python Standard Library
string numbers
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools time
heapq filecmp
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools time
heapq filecmp threading
weakref tempfile
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools time
heapq filecmp threading
weakref tempfile concurrent
copy glob
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools time
heapq filecmp threading
weakref tempfile concurrent
copy glob email
pprint linecache
Python Standard Library
string numbers pickle
difflib fraction marshal
textwrap random configparser
struct itertools hashlib
codecs operator logging
datetime functools time
heapq filecmp threading
weakref tempfile concurrent
copy glob email
pprint linecache etc., etc., etc!
Write
Write
Read
Write
Read
Discover
Write
Read
Discover
Adventure!