Advanced Python functions

There's much more to Python functions than "def". Learn how functions really work, including advanced parameters and scoping.

About The Course

Defining functions is no natural and easy in Python, it’s easy to think that there isn’t much to them.

 

But in fact, Python’s functions are extremely sophisticated. They’re compiled into byte codes. They support many different ways to map arguments to parameters, You can nest functions, returning closures. And that’s just the beginning.

 

In this course, you’ll go way beyond “def” and simple parameters, to really understand what’s happening under the hood in Python functions. You’ll write inner functions and use closures. You’ll even explore stack frames, and see how they can help us understand how Python does things.

 

If you write functions — and as a Python coder, you almost certainly do — but want to really understand them in depth, then this course is for you, with not only a better theoretical understanding, but also practical tips and tools for your day-to-day coding.

This Course Will Show You How To...

All of Python's parameter types, and how arguments are mapped to them

How bytecodes work

What hidden information is contained in a function's __code__ object

How nested functions work, and why you would want to use them

How variables are stored in stack frames

Preview The Course

Function objects and bytecode
Unpacking *iterables and **dicts

Scoping - LEGB

Course Contents

Course Length

4 Hours

Number of Lessons

37

Training Materials

5 PDFs

Coding Exercises

7

  • Welcome (2 mins)
  • Introduction to function objects (5 mins)
  • Function objects and bytecode (8 mins)
  • arguments and local variables (4 mins)
  • Disassembling our function (7 mins)
  • More arguments (4 mins)
  • Defaults (12 mins)
  • Disassembling defaults (6 mins)
  • *args (7 mins)
  • keyword-only parameters (7 mins)
  • Exercises 1 (3 mins)
  • Exercises 1 solutions (9 mins)
  • **kwargs (9 mins)
  • When to use **kwargs (8 mins)
  • Unpacking *iterables and **dicts (6 mins)
  • Writing function wrappers (5 mins)
  • Exercises 2 (2 mins)
  • Exercise 2 solutions (7 mins)
  • Exploring __code__ (14 mins)
  • Scoping – LEGB (18 mins)
  • Inner functions (6 mins)
  • visualizing inner functions (4 mins)
  • Enclosing variables (8 mins)
  • Using enclosing variables (6 mins)
  • nonlocal (10 mins)
  • __code__ and enclosing scope (5 mins)
  • Multiple nestings (5 mins)
  • Use case 1 – Semi-static variables (7 mins)
  • Use case 2 – Function factories (4 mins)
  • Exercises 3 (3 mins)
  • Exercise 3 solutions (6 mins)
  • Intro to stack frames (8 mins)
  • Functions vs. frames (4 mins)
  • The “inspect” module 
  • Inspecting stack frames (7 mins)
  • Type annotations (8 mins)
  • Conclusion (2 mins)

This Course Is Perfect For...

Python developers who feel comfortable writing functions, including with default parameters, who want to take their knowlege to the next level.

GET STARTED NOW

Monthly

Annual

Save 20%

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Nested functions and closures
  • Dig into byte codes
  • Advanced techniques

OR

GET A MEMBERSHIP

Access All My Training
$ 40 Per Month
  • All my Python courses
  • Monthly office hours + special events
  • Private forum for the community

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Nested functions and closures
  • Dig into byte codes
  • Advanced techniques

OR

GET A MEMBERSHIP

Access All My Training
$ 400 Per Year
  • All my Python courses
  • Montly office hourse + special events
  • Private forum for the community

100% Money Back Guarantee

I’m a one-person company dedicated to improving your career via Python and related technologies. If you haven’t gotten value from any of my courses, then just tell me — and I’ll refund your money.

Meet Your Instructor

Reuven is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China — as well as to people around the world, via his online courses.

Reuven created one of the first 100 Web sites in the world just after graduating from MIT’s computer science department. He opened Lerner Consulting in 1995, and has been offering training services since 1996.

In 2020, Reuven published “Python Workout,” a collection of Python exercises with extensive explanations, published by Manning. He’s currently finishing edits on “Pandas Workout,” a similar collection of exercises using the “Pandas” library for data analytics.

Reuven’s free, weekly “Better developers” newsletter, about Python and software engineering, is read by more than 30,000 developers around the globe. His “Trainer weekly” newsletter is popular among people who give corporate training.

Reuven’s most recent venture is Bamboo Weekly: Every Wednesday, he presents a problem based on current events, using a public data set. And every Thursday, he shared detailed solutions to those problems using Pandas.

Reuven’s monthly column appeared in Linux Journal from 1996 until the magazine’s demise in 2019. He was also a panelist on both the Business of Freelancing and Freelancers Show podcasts.

Reuven has a bachelor’s degree in computer science and engineering from MIT, and a PhD in learning sciences from Northwestern University. He lives in Modi’in, Israel with his wife and three children.