Code Monkey home page Code Monkey logo

metaprogramming-python's Introduction

markmap
colorFreezeLevel initialExpandLevel maxWidth
3
2
400

Metaprogramming with Python

  • A small course to explain metaprogramming in Python.
  • This has been prepared for a 1,5h workshop and shared for everyone interested.

Explained in Markdown to allow a conversion to mindmap using Markmap. Each chapter will have code snippets under "workshop" folder to explain with examples.

Tools needed

  • Python 3.10
  • Jupyter Notebook (pip3 install notebook)
  • (optional) MarkDown with VSCode+Markmap

Summary

  • Introduction
    • What is a Class
    • Meta vs Hierarchy
    • type function
  • Decorators
    • The making of
    • Real world examples
  • Metaclasses
    • Do you need them?
    • Real world examples (don't loose them)

Introduction

  • Meta == Greek word for "beyond"
  • Metadata == data about data
  • Metaprogramming == programs that manipulate programs

What is an object in Python?

  • string
  • A function
  • A class definition
  • An instance of a class
  • Everything

What is a Class in Python?

  • Object that creates a new object, or instance
  • Contains functions and attributes
  • Can create an instance
  • Who creates a class?
    • See the workshop

Hierarchy of classes

  • A class can inherit another
    • Can use all attributes and functions of the base/super class
    • In python any Class is always a derived class, at least of the superclass 'object'
      • See the workshop
  • Multiple inheritance is possible
    • the search for attributes inherited from a parent class goes depth-first, left-to-right, not searching twice

Workshop

  • How classes and instances are created
  • How inheritance work
  • What is type

Decorators

  • Let's do a trip
  • From the concept
  • Through decorator construction
  • Until real examples
  • Workshop
    • The making of a decorator
    • Real world examples

Metaclasses

  • Do we need them?
  • Real world examples

References

metaprogramming-python's People

Contributors

sp-xavi-morales avatar xmorales avatar

Stargazers

Tosti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.