3 ms·
Macros. Macros macros macros. Even if I can't have full-on lisp-y AST macros, I'd kill for relatively simple CPP-ish textual macros, just to cut down on boilerp
by tow21 17y ago
Macros. Macros macros macros. Even if I can't have full-on lisp-y AST macros, I'd kill for relatively simple CPP-ish textual macros, just to cut down on boilerplate code.
Not that the chances are any good, and I can understand why - it would be decidedly un-Pythonic. But it's just mildly frustrating at times when I find myself writing the same coupe of lines of code twenty times within a file, because scoping rules insist they have to be there (reading from locals() is often where it hits me))
- deleted 17y ago[deleted]
- j_baker 17y ago"I'd kill for relatively simple CPP-ish textual macros, just to cut down on boilerplate code." If you're getting enough boilerplate writing Python to want something horrendously evil like C++ macros, you're doing something wrong. Not that there isn't a valid argument for macros for Python in general. To be clear though, Guido has said that he'd be open to the concept of Macros if someone were to come up with a good proposal for them. As far as I know, no one has stepped up the plate though.
- euccastro 17y agoI have used exec and eval as something way better than relatively simple CPP-ish textual macros. What's better, you have all the power of Python string manipulation. If you're reading from locals() a lot you're in evil land anyway. :)
- j_baker 17y agoexec and eval can be powerful. But that's their problem. They're a little bit too powerful.