Re: Creating anonymous functions using eval

2005-08-22 Thread Julian Smith
On 12 Jul 2005 08:28:45 -0700 "Devan L" <[EMAIL PROTECTED]> wrote: [ here's some context: > > I've been playing with a function that creates an anonymous function by > > compiling a string parameter, and it seems to work pretty well: > > > > def fn( text): > > exec 'def foo' + text.st

Re: Creating anonymous functions using eval

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 17:17:46 -0600, Joseph Garvin wrote: > Robert Kern wrote: > >>Not everyone is reading this list in a conveniently threaded >>form >> >> > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. Technology as a substitute for manners

Re: Creating anonymous functions using eval

2005-07-12 Thread Robert Kern
Joseph Garvin wrote: > Robert Kern wrote: > >>Not everyone is reading this list in a conveniently threaded >>form > > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. Good point. Allow me to modify my statement: not all newsreaders/email apps thre

Re: Creating anonymous functions using eval

2005-07-12 Thread Dave Benjamin
Joseph Garvin wrote: > Robert Kern wrote: > >> Not everyone is reading this list in a conveniently threaded form >> >> > Why not? Just about every modern newsgroup reader and e-mail app has a > threaded view option. My newsreader supports threading, but the first message I see in this thread

Re: Creating anonymous functions using eval

2005-07-12 Thread Joseph Garvin
Robert Kern wrote: >Not everyone is reading this list in a conveniently threaded >form > > Why not? Just about every modern newsgroup reader and e-mail app has a threaded view option. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
> You missed Steven's point which is to quote the message to which you are > replying. Not everyone is reading this list in a conveniently threaded > form, so you need to provide some context for them to be able to follow > along. Ah, sorry, I didn't quite get what he was referring to. -- http:/

Re: Creating anonymous functions using eval

2005-07-12 Thread Robert Kern
Devan L wrote: > Well, the string that gets passed is more or less a function > definition, which is then called with exec. I don't see why you'd need > to write a string out with the function definition and then call it. > You could just write the function. > > As for the nested functions, I had

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
Well, the string that gets passed is more or less a function definition, which is then called with exec. I don't see why you'd need to write a string out with the function definition and then call it. You could just write the function. As for the nested functions, I had been presuming that it was

Re: Creating anonymous functions using eval

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 08:28:45 -0700, Devan L wrote: > How is this different from a nested function? Well, "this" is a newsgroup posting written by you. Nested functions in Python are callable objects that exist as attributes of other callable objects, so the two are very different. Alternatively,

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
How is this different from a nested function? -- http://mail.python.org/mailman/listinfo/python-list

Creating anonymous functions using eval

2005-07-12 Thread Julian Smith
I've been playing with a function that creates an anonymous function by compiling a string parameter, and it seems to work pretty well: def fn( text): exec 'def foo' + text.strip() return foo This can be used like: def foo( x): print x( 2, 5) foo( fn( '''