lihaoyi/macropy
View on GitHub ↗ ★ 3,308 TSQL
Macros in Python: quasiquotes, case classes, LINQ and more!
48 mentions on Hacker News by 26 people: 15 stories, 33 comments · first 2013-04-23 · latest 2025-11-29
20082026
-
I actually implemented something of this sorts back in college: MacroPy https://github.com/lihaoyi/macropy
comment by lihaoyi · 2025-11-29 · in PEP 638 – Syntactic Macros -
You can make macros in Python: https://github.com/lihaoyi/macropy (note that that project was started for a class taught by Sussman) There's also a PEP to make them first-class: https://peps.python.org/pep-0638/
comment by Y_Y · 2025-05-30 · in On eval in dynamic languages generally and in Racket specifically (2011) -
…Hissp. https://www.gnu.org/software/m4/ https://threeofwands.com/algebraic-data-types-in-python/ https://github.com/lihaoyi/macropy https://github.com/gilch/hissp
comment by gilch · 2024-11-23 · in Ask HN: What are the nice feature you need in a programming language? -
Maybe MacroPy? https://github.com/lihaoyi/macropy
comment by uyt · 2021-02-25 · in Python for Lisp Programmers (2000) -
…of metaprogramming are already there, it just takes some libraries to put them on your fingertips https://github.com/lihaoyi/macropy The "LISP is homoiconic" trope is oversimplified; the Python stdlib gives access to the compiler, parse…
comment by PaulHoule · 2020-09-26 · in Python Enhancement Proposal 638 – Syntactic Macros -
Not unless there was an older repo that is now gone: https://github.com/lihaoyi/macropy/graphs/contributors https://github.com/hylang/hy/graphs/contributors It looks like macropy started around 6 months after Hy, around a time when Hy had…
comment by tekacs · 2020-05-16 · in Macropy: Syntactic Macros for Python -
https://github.com/lihaoyi/macropy
comment by sitkack · 2020-05-06 · in Python goto implemented with system trace function (2017) -
…mutation one can inflict upon the runtime is magnificent! http://farmdev.com/src/secrets/framehack/ https://github.com/lihaoyi/macropy
comment by sitkack · 2019-08-15 · in Rust 1.37.0 -
Another one? https://github.com/lihaoyi/macropy
comment by klibertp · 2018-09-13 · in Bowler: Safe code refactoring for modern Python -
…to parse conventional languages down to an AST tree, work on the tree, and run that code. See https://github.com/lihaoyi/macropy Sometimes I wonder if the LISP cult is just trying to pretend Noam Chomsky was never born.
comment by PaulHoule · 2018-02-16 · in Just what does “code as data” mean anyway? (2014) -
…while using them is pretty cool, I don't think the implementation of the macros is very nice. [1] https://github.com/lihaoyi/macropy
comment by icebraining · 2018-02-15 · in Homoiconicity isn’t the point (2012) -
…don't need to write a parser, btw, because the stdlib provides one for you (in `ast` module). [1] https://github.com/lihaoyi/macropy
comment by klibertp · 2017-06-29 · in Fantastic DSLs and where to find them -
…https://github.com/lampepfl/dotty/issues/2491 and https://github.com/lihaoyi/Scalite and (say) https://github.com/lihaoyi/macropy . [1]: Properties in Python also have the underlying design of using descriptors, which are a whole other…
comment by tekacs · 2017-05-27 · in Warts of Scala -
I think you would be very pleased with and interested in macropy. https://github.com/lihaoyi/macropy
comment by canjobear · 2016-09-10 · in Changing Python lambda syntax at runtime -
…for "case" classes that produce objects with a similar behavior to "attr.s" generated objects https://github.com/lihaoyi/macropy
comment by d0mine · 2016-08-26 · in Using attrs for everything in Python -
…much more extensive things. 1. https://tomforb.es/automatically-inline-python-function-call... 2. https://github.com/lihaoyi/macropy
comment by orf · 2016-01-25 · in Use JSON files as if they are Python modules -
https://github.com/lihaoyi/macropy
comment by mycelium · 2015-09-08 · in Lisp is still a secret weapon -
…that it's not the most impressive example of what you can do with macros (see my other post). [0]: https://github.com/lihaoyi/macropy#skeletons-in-the-closet
comment by davidshepherd7 · 2015-05-26 · in Macros in Python: quasiquotes, case classes, LINQ and more -
…3.4 support is not quite ready [0], and attempting to install it with `pip3` just fails. [0]: https://github.com/lihaoyi/macropy/issues/32
comment by davidshepherd7 · 2015-05-26 · in Macros in Python: quasiquotes, case classes, LINQ and more -
…I am not sure anyone has ever seriously used this ability. It certainly isn't main stream. Checkout https://github.com/lihaoyi/macropy for inspiration. Norvig agrees with this assessment: http://norvig.com/python-lisp.html . Given that…
comment by timtadh · 2014-11-10 · in Half a decade with Go -
Sweet.js ( http://sweetjs.org ) and MacroPy ( https://github.com/lihaoyi/macropy ) come to mind. Actually "real macros" are just macros which operate on AST instead of on strings, they are hard to do if you have to re-implement language…
comment by klibertp · 2014-08-15 · in Why don't I metaprogram more? -
…repeated "defs", though. Here's another approach based on Macropy (basically, macros for Python): https://github.com/lihaoyi/macropy#pattern-matching .
comment by unignorant · 2014-08-03 · in Pun: A small library to enable pattern matching in JavaScript and CoffeeScript -
Oh yes, you can. But once you're doing that, why stop at a single statement? Why not macros https://github.com/lihaoyi/macropy
comment by anon4 · 2014-03-15 · in Replacing `import` with `accio`: A Dive into Bootstrapping and Python's Grammar -
Indeed you can https://github.com/lihaoyi/macropy
comment by anonymous · 2013-11-09 · in Pyret: A new programming language from the creators of Racket -
…algebraic data types and to perform pattern matching. This is the closest thing i found for that: https://github.com/lihaoyi/macropy
comment by neur0mancer · 2013-10-13 · in Functional Python Made Easy -
Most code don't need __setattr__ level of magic https://github.com/lihaoyi/macropy (search for "Levels of Magic")
comment by d0mine · 2013-08-20 · in Guido van Rossum Deconstructing Twisted's Deferreds -
…this point since most of the features are there. [1] http://docs.python.org/3/library/ast.html [2] https://github.com/lihaoyi/macropy
comment by StefanKarpinski · 2013-08-14 · in Metaprogramming – Julia Language -
if you like to play with the AST, I think you could find useful https://github.com/lihaoyi/macropy
comment by _ZeD_ · 2013-08-07 · in Automatically inline Python function calls -
> Can you add macros to python Yes https://github.com/lihaoyi/macropy
comment by anonymous · 2013-06-25 · in Rarely Asked Questions -
Author here, I just put up a Detailed Guide: https://github.com/lihaoyi/macropy#detailed-guide That goes into more detail of how macros are written, and walks you through writing a simple but useful macro (the quicklambda macro). This…
comment by lihaoyi · 2013-05-13 · in Macros in Python -
Yep, there's an issue for that! https://github.com/lihaoyi/macropy/issues/14 I've also gotten a basic implementation working in the CPython REPL, which requires you to run a function `macro_repl()` before you can use them. A Macro powered…
comment by lihaoyi · 2013-05-13 · in Macros in Python -
It's actually pretty simple and almost all in this file: https://github.com/lihaoyi/macropy/blob/master/macropy/core/... Those already familiar with the imp mechanism and AST module could probably infer it from the description. An…
comment by tekacs · 2013-05-13 · in Macros in Python -
…give a TL;DR on the whole library, but case classes can be used with for example pattern matching ( https://github.com/lihaoyi/macropy#pattern-matching ). The following code: with patterns: Foo(x, Bar(3, z)) << Foo(4, Bar(3, 8)) The…
comment by asm89 · 2013-05-13 · in Macros in Python