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
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
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[
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
-
[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
Hello Peter And NG,
thank you a lot... now I'm blaming myself, how couldn't I see it? I
will probably go for the re.sub (if it is not too complicated, I'm not a
Python expert and even less expert of RegEx things), if not I'll try your
suggestion of sorting the strings by length.
Thanks a lo
[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
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 1 6 /
'PERMX' @P