The Python Apprentice

Learn the Python skills and culture you need to become a productive member of any Python project.
Preview in Mapt

The Python Apprentice

Robert Smallshire, Austin Bingham

3 customer reviews
Learn the Python skills and culture you need to become a productive member of any Python project.
Mapt Subscription
FREE
$29.99/m after trial
eBook
$22.40
RRP $31.99
Save 29%
Print + eBook
$39.99
RRP $39.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$22.40
$39.99
$29.99 p/m after trial
RRP $31.99
RRP $39.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


The Python Apprentice Book Cover
The Python Apprentice
$ 31.99
$ 22.40
Statistics for Machine Learning Book Cover
Statistics for Machine Learning
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $36.98
Add to Cart

Book Details

ISBN 139781788293181
Paperback352 pages

Book Description

Experienced programmers want to know how to enhance their craft and we want to help them start as apprentices with Python. We know that before mastering Python you need to learn the culture and the tools to become a productive member of any Python project. Our goal with this book is to give you a practical and thorough introduction to Python programming, providing you with the insight and technical craftsmanship you need to be a productive member of any Python project. Python is a big language, and it’s not our intention with this book to cover everything there is to know. We just want to make sure that you, as the developer, know the tools, basic idioms and of course the ins and outs of the language, the standard library and other modules to be able to jump into most projects.

Table of Contents

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
Strings with Unicode
The bytes type  – an immutable sequence of bytes
list – a sequence of objects
The dict type – associating keys with values
The 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
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
Scopes in action
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 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
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
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
Chapter 12: Afterword – Just the Beginning
Chapter 13: Virtual Environments
Creating a virtual environment
Activating a virtual environment
Deactivating a virtual environment
Other tools for working with virtual environments
Chapter 14: Packaging and Distribution
Configuring a package with distutils
Installing with distutils
Packaging with distutils
Chapter 15: Installing Third-Party Packages
Installing pip
The Python Package Index
Installing Local Packages with pip
Uninstalling Packages

What You Will Learn

  • Learn the language of Python itself
  • Get a start on the Python standard library
  • Learn how to integrate 3rd party libraries
  • Develop libraries on your own
  • Become familiar with the basics of Python testing

Authors

Table of Contents

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
Strings with Unicode
The bytes type  – an immutable sequence of bytes
list – a sequence of objects
The dict type – associating keys with values
The 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
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
Scopes in action
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 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
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
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
Chapter 12: Afterword – Just the Beginning
Chapter 13: Virtual Environments
Creating a virtual environment
Activating a virtual environment
Deactivating a virtual environment
Other tools for working with virtual environments
Chapter 14: Packaging and Distribution
Configuring a package with distutils
Installing with distutils
Packaging with distutils
Chapter 15: Installing Third-Party Packages
Installing pip
The Python Package Index
Installing Local Packages with pip
Uninstalling Packages

Book Details

ISBN 139781788293181
Paperback352 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Statistics for Machine Learning Book Cover
Statistics for Machine Learning
$ 39.99
$ 28.00
Python: End-to-end Data Analysis Book Cover
Python: End-to-end Data Analysis
$ 71.99
$ 50.40
Deep Learning: Practical Neural Networks with Java Book Cover
Deep Learning: Practical Neural Networks with Java
$ 67.99
$ 47.60
Connect the Dots: Factor Analysis [Video] Book Cover
Connect the Dots: Factor Analysis [Video]
$ 49.99
$ 42.50
Metasploit Revealed: Secrets of the Expert Pentester Book Cover
Metasploit Revealed: Secrets of the Expert Pentester
$ 71.99
$ 50.40
Python for Continuous Delivery and Application Security [Video] Book Cover
Python for Continuous Delivery and Application Security [Video]
$ 124.99
$ 106.25