On 7/23/10 2:05 AM, Steven D'Aprano wrote: > On Thu, 22 Jul 2010 21:23:05 -0700, Stephen Hansen wrote: > >> On 7/22/10 7:47 PM, wheres pythonmonks wrote: > [...] >>> The truth is that I don't intend to use these approaches in anything >>> serious. However, I've been known to do some metaprogramming from time >>> to time. >> >> Depending on how you define "metaprogramming", Python is pretty >> notoriously ill-suited towards the task (more, its basically considered >> a feature it doesn't let you go there) -- or, it allows you to do vast >> amounts of stuff with its few dark magic hooks. I've never had a >> satisfying definition of metaprogramming that more then 50% of any group >> agree with, so I'm not sure which you're looking for. :) > > I disagree strongly at your characterisation that Python is notorious for > being ill-suited towards metaprogramming. I'd say the complete opposite > -- what is considered dark and scary metaprogramming tasks in other > languages is considered too ordinary to even mention in Python.
I rather think you missed my point entirely. 'Depending on how you define "metaprogramming"' The 'Depending' was the most important part of that sentence. You go on to talk about runtime modification of classes and the like. That, Python lets you do quite readily, and then go on to do crazy amounts of without any significant effort. That's one definition of metaprogramming. That one Python does well. The other involves things like macros, or things where you basically write a new sub-language in the language itself to achieve some commonly desired task more efficiently (or just more succinctly). That's another definition of metaprogramming: where its not so much structures (classes, etc) which are modified at runtime (which Python lets you do readily), but the syntax or semantics of the language itself. That Python isn't game for. > [...] >> But! What it doesn't let you do is get clever with syntax and write a >> sort of "simplified" or domain specific language to achieve certain >> sorts of repetitive tasks quickly. You always end up writing normal >> Python that looks like all other Python. > > Exactly... 90% of the time that you think you want a DSL, Python beat you > to it. Yet, that is a branch of what is considered metaprogramming that the OP seems to be asking for, that we do not offer any sort of real support for. I was making this distinction. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/
signature.asc
Description: OpenPGP digital signature
-- http://mail.python.org/mailman/listinfo/python-list