Re: Exec Statement Question

2009-11-30 Thread Victor Subervi
On Mon, Nov 30, 2009 at 1:12 PM, Dave Angel wrote: > Victor Subervi wrote: > >> On Sun, Nov 29, 2009 at 10:23 PM, Dave Angel wrote: >> >> >> >>> exec is a statement, and statements don't have "return values." It's >>> not >>> a function, so there are no parentheses in its syntax, either. exec

Re: Exec Statement Question

2009-11-30 Thread Victor Subervi
On Mon, Nov 30, 2009 at 12:25 PM, Carsten Haese wrote: > Victor Subervi wrote: > > Taking out the parenthesis did it! Thanks. Now, you state this is an > > option of last resort. Although this does indeed achieve my desired aim, > > here is a complete example of what I am trying to achieve. The fo

Re: Exec Statement Question

2009-11-30 Thread Dave Angel
Victor Subervi wrote: On Sun, Nov 29, 2009 at 10:23 PM, Dave Angel wrote: exec is a statement, and statements don't have "return values." It's not a function, so there are no parentheses in its syntax, either. exec is also a technique of last resort; there's nearly always a better/safer

Re: Exec Statement Question

2009-11-30 Thread Carsten Haese
Victor Subervi wrote: > Taking out the parenthesis did it! Thanks. Now, you state this is an > option of last resort. Although this does indeed achieve my desired aim, > here is a complete example of what I am trying to achieve. The following > is from 'createTables2.py': > > for table in tables

Re: Exec Statement Question

2009-11-30 Thread Marco Mariani
Jean-Michel Pichavant wrote: if which == '': i = 0 all = '' while i < len(meanings): table = '%s\n' % meanings[i] table += "\n \n composing HTML like that is painful, bug prone and insecure You should have a look at http://tottinge.blogsome.com/meaningfulnames/ I

Re: Exec Statement Question

2009-11-30 Thread Jean-Michel Pichavant
Victor Subervi wrote: if which == '': i = 0 all = '' while i < len(meanings): table = '%s\n' % meanings[i] table += "\n \n align='center'>%s\n " % names[i] j = 0 for elt in code: if (j + 8) % 8 == 0: table += ' \n' table += ' %s\

Re: Exec Statement Question

2009-11-30 Thread Victor Subervi
On Sun, Nov 29, 2009 at 10:23 PM, Dave Angel wrote: > exec is a statement, and statements don't have "return values." It's not > a function, so there are no parentheses in its syntax, either. exec is also > a technique of last resort; there's nearly always a better/safer/faster way > to accom

Re: Exec Statement Question

2009-11-29 Thread Terry Reedy
Dave Angel wrote: exec is a statement, and statements don't have "return values." It's not a function, In 3.x, it is a function, though the use of print as a statement indicates that the OP was using 2.x. -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec Statement Question

2009-11-29 Thread Dave Angel
Victor Subervi wrote: Hi; I have the following line of code: exec('%s()' % table) where 'table' is a variable in a for loop that calls variables from another script. I've made it so that it only calls one variable. I know for a fact that it's calling that variable in the script because it found

Re: Exec Statement Question

2007-04-10 Thread [EMAIL PROTECTED]
Thanks for the responses everyone. That does make sense to me now. -Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec Statement Question

2007-04-08 Thread Gabriel Genellina
7stud wrote: > On Apr 8, 11:31 pm, "Gregory Piñero" <[EMAIL PROTECTED]> wrote: > > Is there a way to call exec such that it won't have access to any more > > objects than I explicitly give it? > > I think the way it works is that when the def is parsed, a function > object is created and assigned t

Re: Exec Statement Question

2007-04-08 Thread Alex Martelli
Gregory Piñero <[EMAIL PROTECTED]> wrote: > I'm curious why this code isn't working how I expect it to: > > import sys > d=3 > > def func1(a,b,c): > print a,b,c,d > print sys.path > > exec "func1(1,2,3)" in {'func1':func1} > > > returns: > 1 2 3 3 > [ sys.path stuff ] > > Sin

Re: Exec Statement Question

2007-04-08 Thread 7stud
On Apr 8, 11:31 pm, "Gregory Piñero" <[EMAIL PROTECTED]> wrote: > I'm curious why this code isn't working how I expect it to: > > import sys > d=3 > > def func1(a,b,c): > print a,b,c,d > print sys.path > > exec "func1(1,2,3)" in {'func1':func1} > > > returns: > 1 2 3 3 > [ sys.path stu

Re: Exec Statement Question

2007-04-08 Thread Georg Brandl
Gregory Piñero schrieb: > I'm curious why this code isn't working how I expect it to: > > import sys > d=3 > > def func1(a,b,c): > print a,b,c,d > print sys.path > > exec "func1(1,2,3)" in {'func1':func1} > > > returns: > 1 2 3 3 > [ sys.path stuff ] > > Since I'm telling exec