Python Meta-Programming

A starter page, needs tighter definitions. Relevance ?

A fairly specialized and obscure subject ... until the advent of Python3.

Metaprogramming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyse or transform other programs, and even modify itself while running ...

Why do that ? After some extra work on the front end, it makes it easier to extend and customize program behavior in the long run ... one hopes.

From the Python Cookbook, mostly Python3.

... In Python, such problems are often solved under the category of "metaprogramming." In a nutshell, metaprogramming is about creating functions and classes whose main goal is to manipulate code (e.g., modifying, generating, or wrapping existing code).

The main features for this include decorators, class decorators, and metaclasses. However, a variety of other useful topics—including signature objects, execution of code with exec(), and inspecting the internals of functions and classes—enter the picture. ... - Python 2.7

Also See

What are the different 'types' of programming ? Object-oriented, aspect oriented, whatever oriented, etc. etc.

In computer programming, the notion of programming paradigms can have somewhat different meanings depending on its context of use ... Involving ...

As soon as I hear a definition that includes the words 'involving blah blah', I know I'm in trouble !

... functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements ...

Seems to be some sort of overlap with meta-programming, but not clear what.

Last modified 11 months ago Last modified on 06/05/2016 03:01:32 PM