Learn Python programming an in-depth introduction to the fundamentals of Python

This book will help you explore the foundations of Python programming and learn how Python can be used to achieve results.

Detalles Bibliográficos
Otros Autores: Romano, Fabrizio, author (author), Kruger, Heinrich, author
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham : Packt 2021.
Edición:3rd edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009635720806719
Tabla de Contenidos:
  • Cover
  • Copyright
  • Contributors
  • Table of Contents
  • Preface
  • Chapter 1: A Gentle Introduction to Python
  • A proper introduction
  • Enter the Python
  • About Python
  • Portability
  • Coherence
  • Developer productivity
  • An extensive library
  • Software quality
  • Software integration
  • Satisfaction and enjoyment
  • What are the drawbacks?
  • Who is using Python today?
  • Setting up the environment
  • Python 2 versus Python 3
  • Installing Python
  • Setting up the Python interpreter
  • About virtual environments
  • Your first virtual environment
  • Installing third-party libraries
  • Your friend, the console
  • How to run a Python program
  • Running Python scripts
  • Running the Python interactive shell
  • Running Python as a service
  • Running Python as a GUI application
  • How is Python code organized?
  • How do we use modules and packages?
  • Python's execution model
  • Names and namespaces
  • Scopes
  • Objects and classes
  • Guidelines for writing good code
  • Python culture
  • A note on IDEs
  • Summary
  • Chapter 2: Built-In Data Types
  • Everything is an object
  • Mutable or immutable? That is the question
  • Numbers
  • Integers
  • Booleans
  • Real numbers
  • Complex numbers
  • Fractions and decimals
  • Immutable sequences
  • Strings and bytes
  • Encoding and decoding strings
  • Indexing and slicing strings
  • String formatting
  • Tuples
  • Mutable sequences
  • Lists
  • Bytearrays
  • Set types
  • Mapping types: dictionaries
  • Data types
  • Dates and times
  • The standard library
  • Third-party libraries
  • The collections module
  • namedtuple
  • defaultdict
  • ChainMap
  • Enums
  • Final considerations
  • Small value caching
  • How to choose data structures
  • About indexing and slicing
  • About names
  • Summary
  • Chapter 3: Conditionals and Iteration
  • Conditional programming
  • A specialized else: elif
  • The ternary operator.
  • Looping
  • The for loop
  • Iterating over a range
  • Iterating over a sequence
  • Iterators and iterables
  • Iterating over multiple sequences
  • The while loop
  • The break and continue statements
  • A special else clause
  • Assignment expressions
  • Statements and expressions
  • Using the walrus operator
  • A word of warning
  • Putting all this together
  • A prime generator
  • Applying discounts
  • A quick peek at the itertools module
  • Infinite iterators
  • Iterators terminating on the shortest input sequence
  • Combinatoric generators
  • Summary
  • Chapter 4: Functions, the Building Blocks of Code
  • Why use functions?
  • Reducing code duplication
  • Splitting a complex task
  • Hiding implementation details
  • Improving readability
  • Improving traceability
  • Scopes and name resolution
  • The global and nonlocal statements
  • Input parameters
  • Argument-passing
  • Assignment to parameter names
  • Changing a mutable object
  • Passing arguments
  • Positional arguments
  • Keyword arguments
  • Iterable unpacking
  • Dictionary unpacking
  • Combining argument types
  • Defining parameters
  • Optional parameters
  • Variable positional parameters
  • Variable keyword parameters
  • Positional-only parameters
  • Keyword-only parameters
  • Combining input parameters
  • More signature examples
  • Avoid the trap! Mutable defaults
  • Return values
  • Returning multiple values
  • A few useful tips
  • Recursive functions
  • Anonymous functions
  • Function attributes
  • Built-in functions
  • Documenting your code
  • Importing objects
  • Relative imports
  • One final example
  • Summary
  • Chapter 5: Comprehensions and Generators
  • The map, zip, and filter functions
  • map
  • zip
  • filter
  • Comprehensions
  • Nested comprehensions
  • Filtering a comprehension
  • Dictionary comprehensions
  • Set comprehensions
  • Generators
  • Generator functions.
  • Going beyond next
  • The yield from expression
  • Generator expressions
  • Some performance considerations
  • Don't overdo comprehensions and generators
  • Name localization
  • Generation behavior in built-ins
  • One last example
  • Summary
  • Chapter 6: OOP, Decorators, and Iterators
  • Decorators
  • A decorator factory
  • Object-oriented programming (OOP)
  • The simplest Python class
  • Class and object namespaces
  • Attribute shadowing
  • The self argument
  • Initializing an instance
  • OOP is about code reuse
  • Inheritance and composition
  • Accessing a base class
  • Multiple inheritance
  • Method resolution order
  • Class and static methods
  • Static methods
  • Class methods
  • Private methods and name mangling
  • The property decorator
  • The cached_property decorator
  • Operator overloading
  • Polymorphism - a brief overview
  • Data classes
  • Writing a custom iterator
  • Summary
  • Chapter 7: Exceptions and Context Managers
  • Exceptions
  • Raising exceptions
  • Defining your own exceptions
  • Tracebacks
  • Handling exceptions
  • Not only for errors
  • Context managers
  • Class-based context managers
  • Generator-based context managers
  • Summary
  • Chapter 8: Files and Data Persistence
  • Working with files and directories
  • Opening files
  • Using a context manager to open a file
  • Reading and writing to a file
  • Reading and writing in binary mode
  • Protecting against overwriting an existing file
  • Checking for file and directory existence
  • Manipulating files and directories
  • Manipulating pathnames
  • Temporary files and directories
  • Directory content
  • File and directory compression
  • Data interchange formats
  • Working with JSON
  • Custom encoding/decoding with JSON
  • I/O, streams, and requests
  • Using an in-memory stream
  • Making HTTP requests
  • Persisting data on disk
  • Serializing data with pickle.
  • Saving data with shelve
  • Saving data to a database
  • Summary
  • Chapter 9: Cryptography and Tokens
  • The need for cryptography
  • Useful guidelines
  • Hashlib
  • HMAC
  • Secrets
  • Random numbers
  • Token generation
  • Digest comparison
  • JSON Web Tokens
  • Registered claims
  • Time-related claims
  • Authentication-related claims
  • Using asymmetric (public key) algorithms
  • Useful references
  • Summary
  • Chapter 10: Testing
  • Testing your application
  • The anatomy of a test
  • Testing guidelines
  • Unit testing
  • Writing a unit test
  • Mock objects and patching
  • Assertions
  • Testing a CSV generator
  • Boundaries and granularity
  • Testing the export function
  • Final considerations
  • Test-driven development
  • Summary
  • Chapter 11: Debugging and Profiling
  • Debugging techniques
  • Debugging with print
  • Debugging with a custom function
  • Using the Python debugger
  • Inspecting logs
  • Other techniques
  • Reading tracebacks
  • Assertions
  • Where to find information
  • Troubleshooting guidelines
  • Where to inspect
  • Using tests to debug
  • Monitoring
  • Profiling Python
  • When to profile
  • Measuring execution time
  • Summary
  • Chapter 12: GUIs and Scripting
  • First approach: scripting
  • The imports
  • Parsing arguments
  • The business logic
  • Second approach: a GUI application
  • The imports
  • The layout logic
  • The business logic
  • Fetching the web page
  • Saving the images
  • Alerting the user
  • How can we improve the application?
  • Where do we go from here?
  • The turtle module
  • wxPython, Kivy, and PyQt
  • The principle of least astonishment
  • Threading considerations
  • Summary
  • Chapter 13: Data Science in Brief
  • IPython and Jupyter Notebook
  • Using Anaconda
  • Starting a Notebook
  • Dealing with data
  • Setting up the Notebook
  • Preparing the data
  • Cleaning the data
  • Creating the DataFrame.
  • Unpacking the campaign name
  • Unpacking the user data
  • Cleaning everything up
  • Saving the DataFrame to a file
  • Visualizing the results
  • Where do we go from here?
  • Summary
  • Chapter 14: Introduction to API Development
  • What is the Web?
  • How does the Web work?
  • Response status codes
  • Type hinting: An overview
  • Why type hinting?
  • Type hinting in a nutshell
  • APIs: An introduction
  • What is an API?
  • What is the purpose of an API?
  • API protocols
  • API data-exchange formats
  • The railway API
  • Modeling the database
  • Main setup and configuration
  • Adding settings
  • Station endpoints
  • Reading data
  • Creating data
  • Updating data
  • Deleting data
  • User authentication
  • Documenting the API
  • Consuming an API
  • Calling the API from Django
  • Where do we go from here?
  • Summary
  • Chapter 15: Packaging Python Applications
  • The Python Package Index
  • The train schedule project
  • Packaging with setuptools
  • Required files
  • pyproject.toml
  • License
  • README
  • Changelog
  • setup.cfg
  • setup.py
  • MANIFEST.in
  • Package metadata
  • Accessing metadata in your code
  • Defining the package contents
  • Accessing package data files
  • Specifying dependencies
  • Entry points
  • Building and publishing packages
  • Building
  • Publishing
  • Advice for starting new projects
  • Alternative tools
  • Further reading
  • Summary
  • Why subscribe?
  • Packt Page
  • Other Books You May Enjoy
  • Index.