[OT] Re: String Replace Problem...

2005-02-28 Thread Steven Bethard
Sean McIlroy wrote: Alright, now it's too much. It's not enough that you're eliminating it from the language, you have to stigmatize the lambda as well. You misunderstand me. I don't have a problem with lambda when it's appropriate, e.g. when used as an expression, where a statement is forbidden

Re: String Replace Problem...

2005-02-28 Thread Sean McIlroy
Alright, now it's too much. It's not enough that you're eliminating it from the language, you have to stigmatize the lambda as well. You should take some time to reflect that not everybody thinks the same way. Those of us who are mathematically inclined like the lambda because it fits in well with

Re: String Replace Problem...

2005-02-28 Thread Steven Bethard
Sean McIlroy wrote: f = lambda x: (x[0]=='@' and x[6:] + '.0') or (x=='/' and x + '\n') or x See "Inappropriate use of Lambda" in http://www.python.org/moin/DubiousPython. You're creating a named function, so there's no reason to use the anonymous function syntax. Try: def f(x): return (x[

Re: String Replace Problem...

2005-02-28 Thread Sean McIlroy
I can't claim to have studied your problem in detail, but I get reasonable results from the following: filename = 'Errors.txt' S = open(filename,'r').read().split() f = lambda x: (x[0]=='@' and x[6:] + '.0') or (x=='/' and x + '\n') or x open(filename,'w').write(' '.join(map(f,S))) HTH -

Re: String Replace Problem...

2005-02-28 Thread wes weston
[EMAIL PROTECTED] wrote: Hello NG, probably this is a basic question, but I'm going crazy... I am unable to find an answer. Suppose that I have a file (that I called "Errors.txt") which contains these lines: MULTIPLY 'PERMX' @PERMX1 1 34 1 20 1 6 / 'PERMX' @PERMX2 1 34 21 41

Re: String Replace Problem...

2005-02-28 Thread Peter Hansen
[EMAIL PROTECTED] wrote: 'PERMX' @PERMX1 1 34 1 20 1 6 / ... 'PERMX' @PERMX10 1 34 21 41 29 34/ ... I would like to replace all the occurrencies of the "keywords" (beginning with the @ (AT) symbol) with some floating point value. As an example, this is what I do: # Find All Keyw