Check out COG (http://www.nedbatchelder.com/code/cog/), a macro system for any language created by Ned Batchelder (http://www.nedbatchelder.com/).
I'm not sure if that's what you're looking for, but allows some good macro capabilities. Thanks, Ryan -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Shannon Sent: Thursday, January 27, 2005 4:35 PM To: tutor@python.org Subject: Re: [Tutor] Syntax Check Chad Crabtree wrote: > I'm trying to make a macro system that's work by just doing this > > import macro > # [...] Perhaps you could turn things around, and make your macro preprocessor into an import hook? I.E., you'd use it like -- import macro module = macro.import("module_with_macros"[, macro_list]) module.do_stuff() Not sure if you'd need to have a list of macros in the module to be imported, or not. Perhaps the macro module would hold a list of currently active macros, instead... In any case, this (I think) gives you a chance to interrupt the import process and modify the target module before the Python parser gets it, which should enable you to avoid the SyntaxError problems. (Of course, I've never messed around with hooking __import__(), so I could just be talking out of my ...) Jeff Shannon Technician/Programmer Credit International _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor