Python 3: Deep Dive (Part 1)

Python 3: Deep Dive (Part 1)
Python 3: Deep Dive (Part 1)
English | MP4 | AVC 1280×720 | AAC 48KHz 2ch | 44.5 Hours | 9.71 GB

Variables, Functions and Functional Programming, Closures, Decorators, Modules and Packages

If you’re looking at this course, you are already interested in Python, and I’m not going to sell you on it.

You already know that this popular language is great for solving a huge variety of tasks from REST api development, system scripting, numerical analysis, manipulating data, data analysis to machine learning and AI.

But do you want to learn idiomatic Python?

Do you want to understand why certain things work the way they do in Python?

Do you want to learn best practices in Python, and common pitfalls Python developers can fall into?

Do you want to become a proficient Python programmer and well on the way to becoming an expert?

Instead of just giving you a 5 minute explanation of how to do something in Python that barely scratches the surface, leaving you open to bad practices and pitfalls, I will provide you a much deeper understanding of the how and why of various concepts.

I will not only show you various ways to code common patterns, but also show you the Pythonic way to do the same.

This is not about learning library XYZ, or glossing over important Python language features. This course focuses on the Python language and the standard library which provides a huge amount of functionality – something you should know about before reaching for 3rd party libraries.

Here you’ll start learning what it takes to become an expert Python developer, and the best resources to dive even deeper if you need to.

We look at a variety of topics in detail.

For example, numbers: Next time you have to use real numbers in your application you’ll truly understand why floats behave the way they do and whether you should use a Decimal or Fraction instead (and know how to do it).

Do you know why you should almost never use equality testing (==) with floats?
0.1 + 0.1 + 0.1 == 0.3 –> False!

Do you know why the float 0.1 actually looks like: 0.100000000000000005551115123126
whereas 0.125 is stored exactly as 0.125000000000000000000000000000?

Do you understand integer division and the mod (%) operator? For negative numbers? Do you want to understand why they behave that way and avoid potential bugs in your code?

For example:

2 % 3 –> 2
-2 % 3 –> 1
2 % -3 –> -1

and

10 // 3 –> 3
-10 // 3 –> -4
-10 // -3 –> 4

Do you truly understand how the boolean operators work?
Do you know what this code does:
a = True
b = False

x = a or b
x –> True

Good. How about this?

a = None
b = ‘python’

x = a or b
x –> ‘python’

Do you want to know why?

Do you know about Python’s associated truth values (truthiness)? And how to leverage this to write cleaner, more Pythonic, code?

How about comprehensions? Would you rather learn to code this way:

def sum_cubes(lst):
sum = 0
for i in range(len(lst)):
sum = sum + lst[i] ** 3
return sum

or this way:

def sum_cubes(lst):
return sum(e ** 3 for e in lst)

Or converting a string into a list of tuples with the index and characters?

The non-Pythonic way to do it:
lst = []
for i in len(lst(s)):
lst.append((i, s[i]))

or the Pythonic way:

lst = list(enumerate(s))

And 9 times out of 10, you probably don’t even need the list there!

Do you want to know how to fully leverage the hyper flexible way to specify function arguments in Python?

Do you understand this? def my_func(a, b=10, *args, key1, key2=None, **kwargs)

Do you want to learn how to pack and unpack arguments? And iterables in general?

Do you know what this does?
a, b, *_, x, y = some_list

or this?
x, y = y, x
x, y, z = y, z, x

Do you want to know why using a mutable type for function parameter defaults is dangerous? Or a function call? But also learn where you can use it to your advantage?

Can you spot the problem in this “logging” function?

def log(msg, event_time = datetime.utcnow()):
print(f'{event_time}: {msg}’)

log(‘message 1’)
# 5 minutes later…
log(‘message 2′)

Why is the time the same in both cases?

Do you know how to make your custom classes support ordering operators (like <, <=, >, >=, == and !=)? Would you like to know how you can write your own decorator to add this functionality to your classes without having to specify all the possible ordering operators? Or how about using the one that Python’s standard library provides us! How about using decorators to speed up certain function calls using a technique called memoization?

Do you want to learn more about the map, reduce and filter functions? And how comprehensions all but eliminate the need to use them? Or how about partial functions and lambda equivalents? The operator module?

Speaking of lambdas? How about the difference between a “standard” function and a lambda expression?

def say_hello(name):
return f’Hello {name}!’

vs

say_hello = lambda name: f’Hello {name}!’

Hint: they’re the same thing! Lambdas are NOT closures by the way.

Do you think everything needs to be a class? Especially if you have a background in languages such as Java or C#? Welcome to Python’s first-class functions and decorators!

Speaking of decorators, do you know how to create one?

Can you now extend this to create decorators that can also accept parameters?
How about decorating classes? Or decorating functions using decorator classes?

Do you know what the @wraps decorator does? Do you want to know how it does that?
The next time you encounter decorators you’ll understand exactly how they work – they’re not magical, and actually very easy once you have understood what closures are, how they work, and how we can leverage them and the fact that Python is a dynamic language.

Single dispatch generic functions? What are they? How do we create them ourselves? What’s in the standard library?

Do you think tuples are just read-only lists? Are you sure a tuple can never change over time? Guess again – we learn the true meaning of immutability and how variables map to objects in memory.

How about using tuples to return multiple values. Or better yet, using named tuples. And specifying default values for your named tuples.

Do you know the difference between a module and a package? namespace packages?

Did you know you can store and run your Python apps directly from inside zip archives?

Do you understand what imports do and how you can control the visible portion of your packages using imports? Do you know the difference between the various flavors of import (from … import …, import …, etc)?

In part 1 of this series, we focus on variables, memory references, memory management, and functional programming, covering topics like numeric data types, Boolean and comparison operators, first-class functions, lambdas, closures, decorators, introspection, tuples as data structures and all about namespaces, modules and packages.

This course will also grow over time as I keep adding useful videos on common questions, pitfalls and idiomatic Python (See the extras section). If you have special requests, let me know!

In upcoming parts of this series, we’ll deep dive in topics such as exceptions, iterables and iterators, generators, hash maps (dictionaries and sets), object oriented concepts, asynchronous programming and meta programming.

All within the context of standard Python and the standard library.

Each topic is usually split into a lecture and coding session. The Jupyter notebooks are fully annotated and available with every coding video, as well as through a GitHub repository.

Table of Contents

Introduction
1 Course Overview
2 Pre-Requisites
3 Code Projects and Notebooks

A Quick Refresher – Basics Review
4 Introduction
5 Classes
6 The Python Type Hierarchy
7 Multi-Line Statements and Strings
8 Variable Names
9 Conditionals
10 Functions
11 The While Loop
12 Break, Continue and the Try Statement
13 The For Loop

Variables and Memory
14 Introduction
15 Variable Equality
16 Everything is an Object
17 Python Optimizations Interning
18 Python Optimizations String Interning
19 Python Optimizations Peephole
20 Variables are Memory References
21 Reference Counting
22 Garbage Collection
23 Dynamic vs Static Typing
24 Variable Re-Assignment
25 Object Mutability
26 Function Arguments and Mutability
27 Shared References and Mutability

Numeric Types
28 Introduction
29 Floats Equality Testing – Lecture
30 Floats Equality Testing – Coding
31 Floats Coercing to Integers – Lecture
32 Floats Coercing to Integers – Coding
33 Floats Rounding – Lecture
34 Floats Rounding – Coding
35 Decimals – Lecture
36 Decimals – Coding
37 Decimals Constructors and Contexts – Lecture
38 Decimals Constructors and Contexts – Coding
39 Integers Data Types
40 Decimals Math Operations – Lecture
41 Decimals Math Operations – Coding
42 Decimals Performance Considerations
43 Complex Numbers – Lecture
44 Complex Numbers – Coding
45 Booleans
46 Booleans Truth Values – Lecture
47 Booleans Truth Values – Coding
48 Booleans Precedence and Short-Circuiting – Lecture
49 Booleans Precedence and Short-Circuiting – Coding
50 Integers Operations
51 Booleans Boolean Operators – Lecture
52 Booleans Boolean Operators – Coding
53 Comparison Operators
54 Integers Constructors and Bases – Lecture
55 Integers Constructors and Bases – Coding
56 Rational Numbers – Lecture
57 Rationals Numbers – Coding
58 Floats Internal Representations – Lecture
59 Floats Internal Representations – Coding

Function Parameters
60 Introduction
61 args – Coding
62 Keyword Arguments – Lecture
63 Keyword Arguments – Coding
64 kwargs
65 Putting it all Together – Lecture
66 Putting it all Together – Coding
67 Application A Simple Function Timer
68 Parameter Defaults – Beware!!
69 Parameter Defaults – Beware Again!!
70 Argument vs Parameter
71 Positional and Keyword Arguments – Lecture
72 Positional and Keyword Arguments – Coding
73 Unpacking Iterables – Lecture
74 Unpacking Iterables – Coding
75 Extended Unpacking – Lecture
76 Extended Unpacking – Coding
77 args – Lecture

First-Class Functions
78 Introduction
79 Callables
80 Map, Filter, Zip and List Comprehensions – Lecture
81 Map, Filter, Zip and List Comprehensions – Coding
82 Reducing Functions – Lecture
83 Reducing Functions – Coding
84 Partial Functions – Lecture
85 Partial Functions – Coding
86 The operator Module – Lecture
87 The operator Module – Coding
88 Docstrings and Annotations – Lecture
89 Docstrings and Annotations – Coding
90 Lambda Expressions – Lecture
91 Lambda Expressions – Coding
92 Lambdas and Sorting
93 Challenge – Randomize an Iterable using Sorted!!
94 Function Introspection – Lecture
95 Function Introspection – Coding

Scopes, Closures and Decorators
96 Introduction
97 Decorators (Part 1) – Lecture
98 Decorators (Part 1) – Coding
99 Decorator Application (Timer)
100 Decorator Application (Logger, Stacked Decorators)
101 Decorator Application (Memoization)
102 Decorators (Part 2) – Lecture
103 Decorators (Part 2) – Coding
104 Decorator Application (Decorator Class)
105 Decorator Application (Decorating Classes)
106 Decorator Application (Dispatching) – Part 1
107 Global and Local Scopes – Lecture
108 Decorator Application (Dispatching) – Part 2
109 Decorator Application (Dispatching) – Part 3
110 Global and Local Scopes – Coding
111 Nonlocal Scopes – Lecture
112 Nonlocal Scopes – Coding
113 Closures – Lecture
114 Closures – Coding
115 Closure Applications – Part 1
116 Closure Applications – Part 2

Tuples as Data Structures and Named Tuples
117 Introduction
118 Named Tuples – Application – Returning Multiple Values
119 Named Tuples – Application – Alternative to Dictionaries
120 Tuples as Data Structures – Lecture
121 Tuples as Data Structures – Coding
122 Named Tuples – Lecture
123 Named Tuples – Coding
124 Named Tuples – Modifying and Extending – Lecture
125 Named Tuples – Modifying and Extending – Coding
126 Named Tuples – DocStrings and Default Values – Lecture
127 Named Tuples – DocStrings and Default Values – Coding

Modules, Packages and Namespaces
128 Introduction
129 What are Packages – Lecture
130 What are Packages – Coding
131 Why Packages
132 Structuring Packages – Part 1
133 Structuring Packages – Part 2
134 Namespace Packages
135 Importing from Zip Archives
136 What is a Module
137 How does Python Import Modules
138 Imports and importlib
139 Import Variants and Misconceptions – Lecture
140 Import Variants and Misconceptions – Coding
141 Reloading Modules
142 Using main
143 Modules Recap

Extras
144 Introduction
145 Random Samples
146 Timing code using timeit
147 Don’t Use args and kwargs Names Blindly
148 Command Line Arguments
149 Sentinel Values for Parameter Defaults
150 Simulating a simple switch in Python
151 Additional Resources
152 Python 3.6 Highlights
153 Python 3.6 – Dictionary Ordering
154 Python 3.6 – Preserved Order of kwargs and Named Tuple Application
155 Python 3.6 – Underscores in Numeric Literals
156 Python 3.6 – f-Strings
157 Random Seeds
158 Random Choices


Download from Rapidgator

Download from Turbobit