The Python Apprentice
The Python Apprentice
$14.99
Minimum price
$19.99
Suggested price
The Python Apprentice

This book is 100% complete

Completed on 2018-10-12

About the Book

The Python Apprentice together with The Python Journeyman and The Python Master comprise a trilogy of books on the Python programming language and the Python Standard Library. The material in these books is derived from Sixty North's popular and battle-tested training courses which have led thousands of programmers on a journey to being productive with Python.

Our books, which use Python 3, follow a spiral curriculum: We introduce topics gently and then revisit them on multiple occasions to add the depth required to support your progression as a Python developer. We've worked hard to structure the syllabus to avoid forward references. On only a few occasions do we require you to accept techniques on trust, before explaining them later; where we do, it's to deliberately establish good habits.

About the Authors

Robert Smallshire
Robert Smallshire

Robert Smallshire is a founding director of Sixty North, a software consulting and training business in Norway providing services throughout Europe, and which uses Python extensively. Robert has worked in senior architecture and technical management roles for several software companies providing tools in the energy sector. He has dealt with understanding, designing, advocating and implementing effective architectures for sophisticated scientific and enterprise software in Python, C++, C# and F# and Javascript. Robert is a regular speaker at conferences, meetups and corporate software events and can be found speaking about topics as diverse as behavioural microeconomics in software development to implementing web services on 8-bit microcontrollers. He is organiser of the Oslo Python group and holds a Ph.D. in a natural science.

Austin Bingham
Austin Bingham

Austin is a founding director of Sixty North, a software consulting, training, and application development company. A native of Texas, in 2008 Austin moved to Stavanger, Norway where he helped develop industry-leading oil reservoir modeling software in C++ and Python. Prior to that he worked at National Instruments developing LabVIEW, at Applied Research Labs (Univ. of Texas at Austin) developing sonar systems for the U.S. Navy, and at a number of telecommunications companies. He is an experienced presenter and teacher, having spoken at numerous conferences, software groups, and internal corporate venues. Austin is also an active member of the open source community, contributing regularly to various Python and Emacs projects, and he’s the founder of Stavanger Software Developers, one of the largest and most active social software groups in Stavanger. Austin holds a Master of Science in Computer Engineering from the University of Texas at Austin.

Bundles that include this book

The Python Apprentice
The Python Journeyman
The Python Master
3 Books
$59.97
Suggested Price
$39.99
Bundle Price

Table of Contents

  • Preface
    • Errata and Suggestions
    • Conventions Used in This Book
  • Welcome Apprentice!
  • Python Promo
  • Overview
  • What is Python?
    • It’s a programming language!
    • It’s a standard library!
    • It’s a philosophy
  • The journey of a thousand miles…
  • Chapter 1 – Getting started
    • Obtaining and installing Python 3
    • Starting Python command line REPL
    • Leaving the REPL
    • Code structure and significant indentation
    • Python culture
    • Importing standard library modules
    • Getting help()
    • Scalar data types: integers, floats, None and bool
    • Relational operators
    • Control flow: if-statements and while-loops
    • Summary
  • Chapter 2 – Strings and collections
    • str – an immutable sequence of Unicode code points
    • Moment of zen
    • bytes – an immutable sequence of bytes
    • list – a sequence of objects
    • dict – associating keys with values
    • For-loops – iterating over series of items
    • Putting it all together
    • Summary
  • Chapter 3 – Modularity
    • Organizing code in a .py file
    • Defining functions
    • Organizing our module into functions
    • The Python execution model
    • Setting up a main function with command line argument
    • Moment of zen
    • Docstrings
    • Comments
    • Shebang
    • Summary
  • Chapter 4 – Built-in types and the object model
    • The nature of Python object references
    • Argument passing semantics – pass by object-reference
    • Python return semantics
    • Function arguments in detail
    • The Python type system
    • Variable declaration and scoping
    • Moment of zen
    • Everything is an object
    • Summary
  • Chapter 5 – Exploring built in collection types
    • tuple – an immutable sequence of objects
    • The tuple constructor
    • Strings in action
    • Moment of zen
    • range – a collection of evenly spaced integers
    • list in action
    • Dictionaries
    • set – an unordered collection of unique elements
    • Collection protocols
    • Summary
  • Chapter 6 – Exceptions
    • Exceptions and control flow
    • Handling exceptions
    • Handling multiple exceptions
    • Programmer errors
    • Empty blocks – the pass statement
    • Exception objects
    • Imprudent return codes
    • Re-raising exceptions
    • Exceptions are part of your function’s API
    • Guard clauses
    • Exceptions, APIs, and protocols
    • Choosing not to guard against TypeError
    • Pythonic style – EAFP versus LBYL
    • Clean-up actions
    • Moment of zen
    • Platform-specific code
    • Summary
  • Chapter 7 - Comprehensions, iterables, and generators
    • Comprehensions
    • Moment of zen
    • Iteration protocols
    • Generator functions
    • Generator expressions
    • “Batteries included” iteration tools
    • Pulling it all together
    • Summary
  • Chapter 8 – Defining new types with classes
    • Defining classes
    • Instance methods
    • Instance initializers
    • Validation and invariants
    • Adding a second class
    • Collaborating classes
    • Moment of zen
    • Booking seats
    • Naming methods for implementation details
    • Sometimes the only object you need is a function
    • Polymorphism and duck-typing
    • Inheritance and implementation sharing
    • Summary
  • Chapter 9 – Files and resource management
    • Files
    • Context managers
    • Moment of zen
    • Binary files
    • File-like objects
    • Other resources
    • Summary
  • Chapter 10 – Unit testing with the Python standard library
    • Test cases
    • Fixtures
    • Assertions
    • Unit testing example: text analysis
    • Using fixtures to create temporary files
    • Using the new fixtures
    • Using assertions to test behavior
    • Testing for exceptions
    • Testing for file existence
    • Moment of zen
    • Summary
  • Chapter 11 – Debugging with PDB
    • Debugging commands
    • Palindrome debugging
    • Summary
  • Afterword: Just the Beginning
  • Appendix A – Virtual environments
    • Creating a virtual environment
    • Activating a virtual environment
    • Deactivating a virtual environment
    • Other tools for working with virtual environments
  • Appendix B – Packaging and distribution
    • Configuring a package with distutils
    • Installing with distutils
    • Packaging with distutils
  • Appendix C – Installing third-party packages
    • Introducing pip
    • The Python Package Index
    • Installing local packages with pip
    • Uninstalling packages
  • Notes

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub