Functions as Objects in Python

133 阅读1分钟
原文链接: medium.com

Functions as Objects in Python

Go to the profile of Chaitanya Baweja
Chaitanya BawejaBlockedUnblockFollowFollowing

One of the most powerful features of Python is that everything is an object, including functions. Functions in Python are first-class objects.

This broadly means, that functions in Python:

  • have types
  • can be sent as arguments to another function
  • can be used in expression
  • can become part of various data structures like dictionaries

Sending functions as arguments coupled with the ability to store them in lists can be extremely helpful. I know all of this can be hard to digest so let’s take this step by step.