Home Top Ad

Python 3: Deep Dive (Part 1)

Python 3: Deep Dive (Part 1)

Python 3: Deep Dive (Part 1)

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

What you’ll learn

  • An in-depth look at variables, memory, namespaces and scopes
  • A deep dive into Python’s memory management and optimizations

  • In-depth understanding and advanced usage of Python’s numerical data types (Booleans, Integers, Floats, Decimals, Fractions, Complex Numbers)

  • Advanced Boolean expressions and operators
  • Advanced usage of callables including functions, lambdas and closures
  • Functional programming techniques such as map, reduce, filter, and partials
  • Create advanced decorators, including parametrized decorators, class decorators, and decorator classes
  • Advanced decorator applications such as memoization and single dispatch generic functions
  • Use and understand Python’s complex Module and Package system
  • Idiomatic Python and best practices
  • Understand Python’s compile-time and run-time and how this affects your code
  • Avoid common pitfalls
Requirements
  • Basic introductory knowledge of Python programming (variables, conditional statements, loops, functions, lists, tuples, dictionaries, classes).
  • You will need Python 3.6 or above, and a development environment of your choice (command line, PyCharm, Jupyter, etc.)

Description

******

Note: This is not a beginner course. Please see prerequisites (or second lecture) before signing up!

Also, Section 2 is a brief review of basic Python, if you are comfortable with Python, please skip it, and start with Section 3

*******

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 mapreduce 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 packagenamespace 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.

Who this course is for:
  • Anyone with a basic understanding of Python that wants to take it to the next level and get a really deep understanding of the Python language and its data structures.
  • Anyone preparing for an in-depth Python technical interview.

Created by Fred Baptiste
Last updated 8/2018
English

Size: 9.57 GB

   Download Now

https://ift.tt/2nohoUU.

The post Python 3: Deep Dive (Part 1) appeared first on Free Course Lab.



from Free Course Lab https://ift.tt/2o76sLm
Python 3: Deep Dive (Part 1) Python 3: Deep Dive (Part 1) Reviewed by P on October 01, 2019 Rating: 5

No comments

FlatBook

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum rhoncus vehicula tortor, vel cursus elit. Donec nec nisl felis. Pellentesque ultrices sem sit amet eros interdum, id elementum nisi ermentum.Vestibulum rhoncus vehicula tortor, vel cursus elit. Donec nec nisl felis. Pellentesque ultrices sem sit amet eros interdum, id elementum nisi fermentum.