Class as Syntactic Sugar of Functions in Python

More explanation coming up, but essentially I’ve tried to define classes with functions in Python for a couple times already, but this time I have something that looks pretty good.

To use it, you just have to provide the class name and instance variables and methods:

make_class(
<class_name>, 
{'__init__': <...>, 'instance_variable_or_method': <...>})

Essentially I used decorators to allow users to define functions that take in self as the first argument but call those functions without self. Also note, the init doesn’t have to return anything just like regular Python. The client code starts at line 22.

Screen Shot 2019-04-08 at 12.39.18 AM.png

 
0
Kudos
 
0
Kudos

Now read this

Lambda Calculus - Church Numerals

So while I was surfing on the internet, I bumped into things I picked when I was in school, lambda calculus being one of them. Now, I admit I’m not a theoretician or even a computer scientist, but this really amazed when I first learned... Continue →