From the course: Python Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Functions as variables

Functions as variables - Python Tutorial

From the course: Python Essential Training

Functions as variables

- [Instructor] Variables have a name and some data associated with them. Functions have a function name and some data associated with them. Okay, in the case of a function, this data is information about the required parameters, if any, and also some lines of instruction need to be executed. And a function is actually represented in Python as an object. And we can see this using the underscore underscore code attribute of Python function objects. Okay, so if I print out co, varnames, let's do print in here and then print co_code. Okay, so here are the variable names. In this case we don't have any. And also a Python byte object of all of the lines of instruction in this function. Now, you'll probably never to actually need to use this. I actually looked it up specifically for this lesson so please don't take notes on underscore underscore code. You're not going to need it. But what you do need to know is that…

Contents