Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread DS
Danny Yoo wrote: >>I hate to admit it, but there are times when fear should be listened to, >>and I think this is one of them. So, I guess I'll move on to parsing it >>myself. Seems a shame though. >> >> > >Hi DS, > >Yeah, I'd recommend listening to fear. *grin* Python's a powerful >languag

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Michael Sparks
On Tuesday 14 February 2006 20:57, Michael Broe wrote: ... > But I can't see a way to do this in a list comprehension: > > >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) > [2, 4, 8, 16] >>> [ x**y for x,y in zip([2,2,2,2],[1,2,3,4]) ] [2, 4, 8, 16] To me this is clearer. (despite having written som

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Danny Yoo
> I read somewhere that the function 'map' might one day be deprecated in > favor of list comprehensions. > > But I can't see a way to do this in a list comprehension: > > >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) > [2, 4, 8, 16] Hi Michael, If my hands were forcibly tied to avoid map(), I'd

Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread Danny Yoo
> I hate to admit it, but there are times when fear should be listened to, > and I think this is one of them. So, I guess I'll move on to parsing it > myself. Seems a shame though. Hi DS, Yeah, I'd recommend listening to fear. *grin* Python's a powerful language, and I'd recommend erring on th

[Tutor] Gadfly Database Problems

2006-02-14 Thread John Corry
Hi, I have a python program that accesses glade and a gadfly database. The program works fine on my computer but I want to compile it so that I can put it on other computers without having to install everything that my computer has. I have had a go at compiling it using py2exe. I have used the

Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread DS
Kent Johnson wrote: >It is very challenging to even come close to safety. If you search >comp.lang.python for eval or exec you will find many discussions of >this. For example >http://groups.google.com/group/comp.lang.python/browse_frm/thread/cf6093c5551a6587/23ddf23a6dfc3e11?q=eval&rnum=1#23ddf

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Michael Broe
On Feb 14, 2006, at 3:46 PM, Andre Roberge wrote: > [2**i for i in [1, 2, 3, 4]] Ah yes, I'm sorry, I was thinking of the most general case, where the arguments are two arbitrary lists. My example was too specific. Is there a way to do something like the following in a list comprehension?

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Kent Johnson
Michael Broe wrote: > I read somewhere that the function 'map' might one day be deprecated > in favor of list comprehensions. > > But I can't see a way to do this in a list comprehension: > > >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) > [2, 4, 8, 16] > > Is there a way? The current plan is to

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Jason Massey
How about: >>> [pow(2,x) for x in [1,2,3,4]] [2, 4, 8, 16] On 2/14/06, Michael Broe <[EMAIL PROTECTED]> wrote: I read somewhere that the function 'map' might one day be deprecatedin favor of list comprehensions.But I can't see a way to do this in a list comprehension: >>> map (pow, [2, 2, 2, 2],

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Andre Roberge
On 2/14/06, Michael Broe <[EMAIL PROTECTED]> wrote: > I read somewhere that the function 'map' might one day be deprecated > in favor of list comprehensions. > > But I can't see a way to do this in a list comprehension: > > >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) > [2, 4, 8, 16] >>> [2**i for i

[Tutor] map vs. list comprehension

2006-02-14 Thread Michael Broe
I read somewhere that the function 'map' might one day be deprecated in favor of list comprehensions. But I can't see a way to do this in a list comprehension: >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) [2, 4, 8, 16] Is there a way? Cheers, Mike ___

Re: [Tutor] Build Python 2.4 SCO OpenServer 5

2006-02-14 Thread Danny Yoo
On Tue, 14 Feb 2006, Paul Kraus wrote: > Everything configures fine but when I build it dies here... > (If this is not the right place for this please point me to where I should be > posting.) Hi Paul, Try the comp.lang.python newsgroup; this installation question seems very specialized, and

[Tutor] Build Python 2.4 SCO OpenServer 5

2006-02-14 Thread Paul Kraus
Everything configures fine but when I build it dies here... (If this is not the right place for this please point me to where I should be posting.) gcc -Wl,-Bexport -o python \ Modules/python.o \ libpython2.4.a -lsocket -lnsl -ldl -lpthread -lm case $MAKEFLAGS

Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread Terry Carroll
On Tue, 14 Feb 2006, Kent Johnson wrote: > Bottom line - it's a very hard problem which I don't think anyone has > solved to the satisfaction of all observers, though there are limited > solutions which some people find acceptable. I think it's telling that the restricted execution modules, rex

Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread Kent Johnson
DS wrote: > I have been writing a web-based application in which users would be able > to input expressions which would be evaluated on the server. I had read > about the dangers of using eval for such things, and so I parse the > expressions myself, and calculate the expressions using my own code

[Tutor] exec, execfile, rexec

2006-02-14 Thread DS
I have been writing a web-based application in which users would be able to input expressions which would be evaluated on the server. I had read about the dangers of using eval for such things, and so I parse the expressions myself, and calculate the expressions using my own code. This wasn't too

Re: [Tutor] lists

2006-02-14 Thread Kent Johnson
Michael Haft wrote: > > > Hello, > I have a list of 15 str values called p, when I try the following > code: > > for x in p: > p[x] = float(p[x])/10 > print p The problem is that iterating a list yields the actual values in the list, not the indices to the list: >>> p = ['1900'

[Tutor] lists

2006-02-14 Thread Michael Haft
Hello, I have a list of 15 str values called p, when I try the following code: for x in p: p[x] = float(p[x])/10 print p I get: Traceback (most recent call last): File "C:/Python24/CRU_2_Century code/CRU_2_DNDC.py", line 62, in -toplevel- p[x] = float(p[x])/10 TypeError: