Re: Getting in to metaprogramming

2008-12-15 Thread eric_dex...@msn.com
On Nov 27, 9:56 pm, "Hendrik van Rooyen" wrote: >  "Steven D'Aprano" > > >GUI designer. You write a program to let the user create code by clicking > >buttons, dragging objects, drawing lines, etc. The GUI designer may use > >classes, but the purpose of those classes is to generate source code. >

Re: Getting in to metaprogramming

2008-11-28 Thread Aaron Brady
On Nov 27, 8:21 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: snip > body = 'L.append(None)\n' > make_file('dumb.py', 'Create a big list the dumb way.', >     'L = []\n', body*numitems) > make_file('smart.py', 'Create a big list the smart way.', >     '', 'L = [None]*%d\n' % num

Re: Getting in to metaprogramming

2008-11-28 Thread Aaron Brady
On Nov 27, 9:28 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >  "Aaron Brady" <[EMAIL PROTECTED]> wrote: ... > >As you can see, the 'visit' method is mechanical for classes A and B. > >One might want to autogenerate those in some languages, but Python has > >introspection: > > >class BaseAB:

Re: Getting in to metaprogramming

2008-11-27 Thread alex23
On Nov 27, 8:55 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Then another thing - it strikes me that any problem that can be solved > by metaprogramming, can be solved by putting similar code into a class > and instanciating an instance. > > Does anybody know if this is true? > > If it is,

Re: Getting in to metaprogramming

2008-11-27 Thread Steven D'Aprano
On Fri, 28 Nov 2008 05:05:10 +0200, Hendrik van Rooyen wrote: > "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > >> Hendrik van Rooyen wrote: >> >> > I am using the term in the restricted sense of Python writing Python >> > source. >> > >> > Given that, can anybody think of an example that you could

Re: Getting in to metaprogramming

2008-11-27 Thread Kay Schluehr
On 27 Nov., 06:11, Rafe <[EMAIL PROTECTED]> wrote: > On Nov 27, 11:41 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> > wrote: > > > > > "Steven D'Aprano" wrote: > > > > Well, I don't know about "any problem". And it's not so much about > > > whether metaprograms can solve problems that can't be sol

Re: Getting in to metaprogramming

2008-11-27 Thread Terry Reedy
Hendrik van Rooyen wrote: "Terry Reedy" <[EMAIL PROTECTED]> wrote: Hendrik van Rooyen wrote: I am using the term in the restricted sense of Python writing Python source. Given that, can anybody think of an example that you could not do with a class? (excepting the "stored procedure" aspec

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
"Michele Simionato" <[EMAIL PROTECTED]> wrote: >The namedtuple recipe by Raymond Hettinger (http:// >code.activestate.com/recipes/500261) >is an interesting example of code generation. My own decorator module >use a similar >trick. Here code generation (plus eval/exec) is needed since you need >c

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
"Kay Schluehr" <[EMAIL PROTECTED]> wrote: > > I just noticed that corepy 1.0 [1] has been released. Corepy is an > embedded DSL for synthesizing machine code from chaining Python > commands. This means it provides objects and exploits control > structures used to create machine code that can f

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
"Steven D'Aprano" <[EMAIL PROTECTED]> >GUI designer. You write a program to let the user create code by clicking >buttons, dragging objects, drawing lines, etc. The GUI designer may use >classes, but the purpose of those classes is to generate source code. > Yikes, this is getting hairy- If "

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > Hendrik van Rooyen wrote: > > > I am using the term in the restricted sense of Python writing Python source. > > > > Given that, can anybody think of an example that you could not do with > > a class? (excepting the "stored procedure" aspect) > > I am

Re: Getting in to metaprogramming

2008-11-27 Thread Hendrik van Rooyen
"Aaron Brady" <[EMAIL PROTECTED]> wrote: >On Nov 26, 10:41 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> >wrote: >> "Steven D'Aprano" wrote: >> >> >> >> > Well, I don't know about "any problem". And it's not so much about >> > whether metaprograms can solve problems that can't be solved by anythi

Re: Getting in to metaprogramming

2008-11-27 Thread Michele Simionato
On Nov 27, 5:41 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Given that, can anybody think of an example that you could not do with > a class?  (excepting the "stored procedure" aspect) The namedtuple recipe by Raymond Hettinger (http:// code.activestate.com/recipes/500261) is an interest

Re: Getting in to metaprogramming

2008-11-27 Thread Lawrence D'Oliveiro
Rafe wrote: > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". Fred Brooks, in his classic "Mythical Man-Month", defined "metaprogramming" as simply a very high-level form of programming, us

Re: Getting in to metaprogramming

2008-11-26 Thread Rafe
On Nov 27, 12:11 pm, Rafe <[EMAIL PROTECTED]> wrote: > On Nov 27, 11:41 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> > wrote: > > > > >  "Steven D'Aprano" wrote: > > > > Well, I don't know about "any problem". And it's not so much about > > > whether metaprograms can solve problems that can't be s

Re: Getting in to metaprogramming

2008-11-26 Thread Rafe
On Nov 27, 11:41 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >  "Steven D'Aprano" wrote: > > > > > Well, I don't know about "any problem". And it's not so much about > > whether metaprograms can solve problems that can't be solved by anything > > else, as whether metaprograms can solve pro

Re: Getting in to metaprogramming

2008-11-26 Thread Aaron Brady
On Nov 26, 6:29 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 27 Nov 2008 06:41:47 +0200, Hendrik van Rooyen wrote: > > I am using the term in the restricted sense of Python writing Python > > source. > > > Given that, can anybody think of an example that you could not do with a > > clas

Re: Getting in to metaprogramming

2008-11-26 Thread Steven D'Aprano
On Thu, 27 Nov 2008 06:41:47 +0200, Hendrik van Rooyen wrote: > I am using the term in the restricted sense of Python writing Python > source. > > Given that, can anybody think of an example that you could not do with a > class? (excepting the "stored procedure" aspect) GUI designer. You write

Re: Getting in to metaprogramming

2008-11-26 Thread Aaron Brady
On Nov 26, 10:41 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >  "Steven D'Aprano" wrote: > > > > > Well, I don't know about "any problem". And it's not so much about > > whether metaprograms can solve problems that can't be solved by anything > > else, as whether metaprograms can solve pro

Re: Getting in to metaprogramming

2008-11-26 Thread Terry Reedy
Hendrik van Rooyen wrote: I am using the term in the restricted sense of Python writing Python source. Given that, can anybody think of an example that you could not do with a class? (excepting the "stored procedure" aspect) I am not sure I understand your question. def iterize(recursive_f

Re: Getting in to metaprogramming

2008-11-26 Thread Kay Schluehr
On 27 Nov., 05:41, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Given that, can anybody think of an example that you could not do with > a class? (excepting the "stored procedure" aspect) I just noticed that corepy 1.0 [1] has been released. Corepy is an embedded DSL for synthesizing machin

Re: Getting in to metaprogramming

2008-11-26 Thread Hendrik van Rooyen
"Steven D'Aprano" wrote: > > Well, I don't know about "any problem". And it's not so much about > whether metaprograms can solve problems that can't be solved by anything > else, as whether metaprograms can solve problems more effectively than > other techniques. > > If you include factory

Re: Getting in to metaprogramming

2008-11-26 Thread Kay Schluehr
On 25 Nov., 11:08, Rafe <[EMAIL PROTECTED]> wrote: > Hi, > > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". That is, using code to write code (right?) > > Cheers, > > - Rafe http://www.letme

Re: Getting in to metaprogramming

2008-11-26 Thread Steven D'Aprano
On Thu, 27 Nov 2008 00:55:33 +0200, Hendrik van Rooyen wrote: > "Aaron Brady" <[EMAIL PROTECTED]> wrote: > > >>I don't know a clean, reliable way to structure a metaprogram though. >>Mine always turn out messy. > > Yes. > > Then another thing - it strikes me that any problem that can be solved

Re: Getting in to metaprogramming

2008-11-26 Thread Michele Simionato
On Nov 26, 11:55 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Then another thing - it strikes me that any problem that can be solved > by metaprogramming, can be solved by putting similar code into a class > and instanciating an instance. > > Does anybody know if this is true? > > If it is

Re: Getting in to metaprogramming

2008-11-26 Thread Hendrik van Rooyen
"Aaron Brady" <[EMAIL PROTECTED]> wrote: >I don't know a clean, reliable way to structure a metaprogram though. >Mine always turn out messy. Yes. Then another thing - it strikes me that any problem that can be solved by metaprogramming, can be solved by putting similar code into a class and ins

Re: Getting in to metaprogramming

2008-11-25 Thread Arnaud Delobelle
Aaron Brady <[EMAIL PROTECTED]> writes: > I don't know a clean, reliable way to structure a metaprogram though. > Mine always turn out messy. I don't think Python is designed for large scale metaprogramming. Lisp is the only naturally suited language that I know. -- Arnaud -- http://mail.pytho

Re: Getting in to metaprogramming

2008-11-25 Thread Aaron Brady
On Nov 25, 5:20 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Nov 25, 12:12 pm, Rafe <[EMAIL PROTECTED]> wrote: > > > is it really as simple as gathering strings of code? > > Yes. Yes. > > Sort of like generating HTML or XML directly? Is there any other framework > > or > > pattern set t

Re: Getting in to metaprogramming

2008-11-25 Thread Stef Mientki
Rafe wrote: On Nov 25, 5:41 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: On Nov 25, 4:08 am, Rafe <[EMAIL PROTECTED]> wrote: Hi, In the name of self-education can anyone share some pointers, links, modules, etc that I might use to begin learning how to do some "metaprogramming".

Re: Getting in to metaprogramming

2008-11-25 Thread Michele Simionato
On Nov 25, 12:12 pm, Rafe <[EMAIL PROTECTED]> wrote: > is it really as simple as gathering strings of code? Yes. > Sort of like generating HTML or XML directly? Is there any other framework or > pattern set that is worth looking in to? Yes, the compiler module and the ast module in the standard

Re: Getting in to metaprogramming

2008-11-25 Thread Rafe
On Nov 25, 5:41 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > On Nov 25, 4:08 am, Rafe <[EMAIL PROTECTED]> wrote: > > > Hi, > > > In the name of self-education can anyone share some pointers, links, > > modules, etc that I might use to begin learning how to do some > > "metaprogramming". That is, us

Re: Getting in to metaprogramming

2008-11-25 Thread Aaron Brady
On Nov 25, 4:08 am, Rafe <[EMAIL PROTECTED]> wrote: > Hi, > > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". That is, using code to write code (right?) > > Cheers, > > - Rafe Python programs

Re: Getting in to metaprogramming

2008-11-25 Thread Michele Simionato
On Nov 25, 11:08 am, Rafe <[EMAIL PROTECTED]> wrote: > Hi, > > In the name of self-education can anyone share some pointers, links, > modules, etc that I might use to begin learning how to do some > "metaprogramming". That is, using code to write code (right?) > > Cheers, > > - Rafe The word "meta

Getting in to metaprogramming

2008-11-25 Thread Rafe
Hi, In the name of self-education can anyone share some pointers, links, modules, etc that I might use to begin learning how to do some "metaprogramming". That is, using code to write code (right?) Cheers, - Rafe -- http://mail.python.org/mailman/listinfo/python-list