Write Pythonic Code Like a Seasoned Developer Transcripts
Chapter: Methods and Functions
Lecture: Introduction to Pythonic functions
0:01 Our next category of Pythonic concepts and tips
0:03 is going to be around functions and methods.
0:06 Python is a multi-paradigm programming language,
0:09 we can write procedural code,
0:10 we could write object-oriented code,
0:12 we could write functional code and with things like decorators
0:15 we can even write aspect-oriented code.
0:17 Python's functional support is very strong,
0:20 you'll see the functions and methods are first class symbols and citizens in Python
0:25 and they are highly flexible and powerful.
0:28 When you define a function or method with a "def" keyword,
0:32 you're really instantiating a function object and you can pass that object around
0:37 just like you can pass a number or a string or an instance of a class.
0:41 You'll see that those function objects can even be changed at runtime
0:45 you could dynamically add a field to a function
0:47 just by saying "function.value=something".
0:50 Not saying that you should do that, but just considering the flexibility, right.
0:55 Functions even allow you create things called closures,
0:57 both inline functions as well as lambda expressions,
1:00 that's a very powerful programming technique often used in places
1:07 And finally with things like lambda expressions
1:09 we can even define small inline methods as little bits of executable code
1:14 that we can pass around in super concise and composable ways.