Python #ifdef

Chris Angelico rosuav at gmail.com
Wed May 29 11:05:35 EDT 2013


On Thu, May 30, 2013 at 12:55 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2013-05-29, Dan Stromberg <drsalists at gmail.com> wrote:
>
>> And in case you still want a preprocessor for Python (you likely don't need
>> one this time), here's an example of doing this using the venerable m4:
>> https://pypi.python.org/pypi/red-black-tree-mod .  Note the many comments
>> added to keep line numbers consistent.
>
> I was wondering whether or not to mention m4.  Since m4 is (in my
> mind) inextricably linked to RATFOR and sendmail config files I try
> to avoid thinking about it lest the flashbacks start again...

It's not a bad tool. I used it as a sort of PHP preprocessor, because
requirements at work had me wanting to have a source file defining a
PHP class and having an autogenerated section in the middle of that
class. PHP's 'include' directive doesn't work for that. Of course, had
we been using a better language, that wouldn't have been an issue (and
it stopped being an issue when we improved the design and stopped
using that class system, too, though I retained the makefile
directives about building .php.m4 -> .php files). But still, GNU M4 is
a decent piece of technology.

ChrisA



More information about the Python-list mailing list