Contribute Media
A thank you to everyone who makes this possible: Read More

More Than You Ever Wanted To Know About Python Functions

Translations: en en


What exactly are functions? Let’s talk about functions, methods, callables and closures - what they are, what you can give them, what they can give you, what you can do with them … and what’s inside.

You probably think you already know everything about functions, but you probably don’t!

Input & Output: How do you get things in and out of functions? I’ll cover parameters and the myriad of ways they can be specified, provided and accessed - including helpful hints to avoid common mistakes! I’ll cover return values, briefly, along with variable scopes and exceptions.

Closures : What are they, how do they work and how they can affect memory usage.

Methods : How does a method differ from a function, when are they made, how do they work (where does self come from?) and how to access the function inside every method.

**magic** :Make your own callables from any object!

Introspection : Using modern Python techniques, what can you find out about a function, and what can you do with that information?

Bytecode : What happens if you open up a function and look at its insides? Can you change it and put it back together again? (Spoiler: Yes, you can.)

By the end of this talk, I guarantee* you’ll know more about callables than when you walked in, along with techniques both practical and so extreme your colleagues will never let you merge them to master.

(*This guarantee is legally non-binding and cannot be redeemed in any way.)


Improve this page