Clover I/O
  • Artificial Intelligence
    • Machine Learning
    • NLP
  • Programming
    • Python
    • C/C++
    • Linux
  • Finance & Economy
  • Development
    • Web Dev
    • Mobile Dev
      • iOS Dev
      • Android Dev
    • Hardware
      • ARM9
      • Raspberry Pi
  • Life Story
    • Talking
    • Languages
      • English
  • Artificial Intelligence
    • Machine Learning
    • NLP
  • Programming
    • Python
    • C/C++
    • Linux
  • Finance & Economy
  • Development
    • Web Dev
    • Mobile Dev
      • iOS Dev
      • Android Dev
    • Hardware
      • ARM9
      • Raspberry Pi
  • Life Story
    • Talking
    • Languages
      • English
Z.ZHANG
10 月 29, 2018 1 min read

Python Meta-programming

In a nutshell: code that manipulates code.

Common examples:

  • Decorators
  • Metaclasses
  • Descriptors

Closures: You can make and return functions.

def make_adder(x, y):
    def add():
        return x + y
    return add

Reference: https://www.ibm.com/developerworks/library/ba-metaprogramming-python/index.html

© 2025 www.cloverio.com