My Account Log in

2 options

The Python apprentice : a practical and thorough introduction to the Python programming language / Robert Smallshire, Austin Bingham.

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Smallshire, Robert, author.
Bingham, Austin, author.
Language:
English
Subjects (All):
Python (Computer program language).
Physical Description:
1 online resource (1 volume) : illustrations
Edition:
1st edition
Place of Publication:
Birmingham, UK : Packt Publishing, 2017.
System Details:
text file
Biography/History:
Smallshire Robert: 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. Bingham Austin: Austin Bingham 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.
Summary:
Learn the Python skills and culture you need to become a productive member of any Python project. About This Book Taking a practical approach to studying Python A clear appreciation of the sequence-oriented parts of Python Emphasis on the way in which Python code is structured Learn how to produce bug-free code by using testing tools Who This Book Is For The Python Apprentice is for anyone who wants to start building, creating and contributing towards a Python project. No previous knowledge of Python is required, although at least some familiarity with programming in another language is helpful. 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 In Detail 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. Style and approach 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.
Contents:
Cover
Copyright
Credits
About the Authors
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Getting started
Obtaining and installing Python 3
Windows
macOS
Linux
Starting Python command line REPL
Leaving the REPL
Unix
Code structure and significant indentation
Python culture
Importing standard library modules
Getting help()
Counting fruit with math.factorial()
Different types of numbers
Scalar data types: integers, floats, None and bool
int
float
Special floating point values
Promotion to float
None
bool
Relational operators
Rich comparison operators
Control flow: if-statements and while-loops
Conditional control flow: The if-statement
if...else
if...elif...else
Conditional repetition: the while-loop
Exiting loops with break
Summary
Chapter 2: Strings and Collections
str - an immutable sequence of Unicode code points
String quoting styles
Moment of zen
Concatenation of adjacent strings
Multiline strings and newlines
Raw strings
The str constructor
Strings as sequences
String methods
Strings with Unicode
The bytes type - an immutable sequence of bytes
Literal bytes
Converting between bytes and str
list - a sequence of objects
The dict type - associating keys with values
The For-loops - iterating over series of items
Putting it all together
Chapter 3: Modularity
Organizing code in a .py file
Running Python programs from the operating system shell
Importing modules into the REPL
Defining functions
Organizing our module into functions
The __name__ type and executing modules from the command line
The Python execution model
The difference between modules, scripts, and programs.
Setting up a main function with command line argument
Accepting command line arguments
Docstrings
Comments
Shebang
Executable Python programs on Linux and Mac
Executable Python programs on Windows
Chapter 4: Built-in types and the object model
The nature of Python object references
Reassigning a reference
Assigning one reference to another
Exploring value vs. identity with id()
Testing for equality of identity with is
Mutating without mutating
References to mutable objects
Equality of value (equivalence) versus equality of identity
Argument passing semantics - pass by object-reference
Modifying external objects in a function
Binding new objects in a function
Argument passing is reference binding
Python return semantics
Function arguments in detail
Default parameter values
Keyword arguments
When are default arguments evaluated?
The Python type system
Dynamic typing in Python
Strong typing in Python
Variable declaration and scoping
The LEGB rule
Scopes in action
Identical names in global and local scope
The global keyword
Everything is an object
Inspecting a function
Chapter 5: Exploring Built-in Collection types
tuple - an immutable sequence of objects
Literal tuples
Tuple element access
The length of a tuple
Iterating over a tuple
Concatenating and repetition of tuples
Nested tuples
Single-element tuples
Empty tuples
Optional parentheses
Returning and unpacking tuples
Swapping variables with tuple unpacking
The tuple constructor
Membership tests
Strings in action
The length of a string
Concatenating strings
Joining strings
Splitting strings
Partitioning strings
String formatting
Other string methods.
range - a collection of evenly spaced integers
Starting value
Step argument
Not using range: enumerate()
list in action
Negative indexing for lists (and other sequences)
Slicing lists
Copying lists
Shallow copies
Repeating lists
Finding list elements with index()
Membership testing with count() and in
Removing list elements by index with del
Removing list elements by value with remove()
Inserting into a list
Concatenating lists
Rearranging list elements
Out-of-place rearrangement
Dictionaries
Copying dictionaries
Updating dictionaries
Iterating over dictionary keys
Iterating over dictionary values
Iterating over key-value pairs
Membership testing for dictionary keys
Removing dictionary items
Mutability of dictionaries
Pretty printing
set - an unordered collection of unique elements
The set constructor
Iterating over sets
Membership testing of sets
Adding elements to sets
Removing elements from sets
Copying sets
Set algebra operations
Union
Intersection
Difference
Symmetric difference
Subset relationships
Collection protocols
Container protocol
Sized protocol
Iterable protocol
Sequence protocol
Other protocols
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
Exceptions raised by Python
Catching exceptions
Raising exceptions explicitly
Guard clauses
Exceptions, APIs, and protocols
IndexError
ValueError
KeyError
Choosing not to guard against TypeError
Pythonic style - EAFP versus LBYL
Clean-up actions
Moment of zen.
Platform-specific code
Chapter 7: Comprehensions, iterables, and generators
Comprehensions
List comprehensions
List comprehension syntax
Elements of a list comprehension
Set comprehensions
Dictionary comprehensions
Comprehension complexity
Filtering comprehensions
Combining filtering and transformation
Iteration protocols
An example of the iteration protocols
A more practical example of the iteration protocols
Generator functions
The yield keyword
Generators are iterators
When is generator code executed?
Maintaining explicit state in the generator function
The first stateful generator: take()
The second stateful generator: distinct()
Understand these generators!
Lazy generator pipelines
Laziness and the infinite
Generating the Lucas series
Generator expressions
[Generator objects only run once]
Generator objects only run once
Iteration without memory
Using an if-clause in generator expressions
Batteries included iteration tools
Introducing itertools
Sequences of booleans
Merging sequences with zip
More than two sequences with zip()
Lazily concatenating sequences with chain()
Pulling it all together
Generators
Iteration tools
Chapter 8: Defining new types with classes
Defining classes
Instance methods
Instance initializers
A lack of access modifiers
Validation and invariants
Adding a second class
Collaborating classes
Booking seats
Allocating seats to passengers
Naming methods for implementation details
Implementing relocate_passenger()
Counting available seats
Sometimes the only object you need is a function
Making Flight create boarding cards
Polymorphism and duck-typing
Refactoring Aircraft.
Inheritance and implementation sharing
A base class for aircraft
Inheriting from Aircraft
Hoisting common functionality into a base class
Chapter 9: Files and Resource Management
Files
Binary and text modes
The important of encoding
Opening a file for writing
Writing to files
Closing files
The file outside of Python
Reading files
Readline line by line
Reading multiple lines at once
Appending to files
File objects as iterators
Context Managers
Managing resources with finally
The with-blocks
Binary files
The BMP file format
Bitwise operators
Writing a BMP file
[Generating fractal images]
Generating fractal images
Reading binary files
File-like objects
You've already seen file-like objects!
Using file-like objects
Other resources
Chapter 10: Unit testing with the Python standard library
Test cases
Fixtures
Assertions
Unit testing example: text analysis
Running the initial tests
Making the test pass
Using fixtures to create temporary files
Using the new fixtures
Using assertions to test behavior
Counting lines
Counting characters
Testing for exceptions
Testing for file existence
Chapter 11: Debugging with PDB
Debugging commands
Palindrome debugging
Bug hunting with PDB
Finding infinite loops with sampling
Setting explicit breaks
Stepping through execution
Fixing the bug
Afterword - Just the Beginning
Virtual Environments
Creating a virtual environment
Activating a virtual environment
Deactivating a virtual environment
Other tools for working with virtual environments
Packaging and Distribution
Configuring a package with distutils
Installing with distutils
Packaging with distutils.
Installing Third-Party Packages.
Notes:
Description based on online resource; title from title page (viewed July 10, 2017).
ISBN:
9781523112203
1523112204
9781788298667
1788298667
OCLC:
993258585

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account