Hey Laura,
[Laura Creighton Wed, Jun 30, 2004 at 04:43:25PM +0200]
> I am still dizzy and sick, but I am trying to get something done anyhow. I have
> this question.
ups, didn't know you were ill, but you seem to have fun recovering :-)
> If you start with
>
> self.assertEquals(f(x) +
> g(x) == q(x), 'Message to print when the assertion fails')
Oh, ^^^^ you mean a comma here, i guess?!
> you would like things to come back as
>
> assert f(x) +\
> g(x) == q(x), 'Message to print when the assertion fails'
actually i'd prefer
assert f(x) + g(x) == q(x), 'Message to print when the assertion fails'
Because i think the output logic should just format it so that it looks
nice (e.g. less < 76 characters per line) and retain the correct
semantics of the original statement. I wouldn't worry about the
original input format, though. If this proves too hard then maybe blame
Armin who suggested the 'comma'-try-parsing-withought-understanding-the
expression-tricks :-)
Regarding your string-parsing question ...
> ...
> But there is this problem.
>
> >>> s='''
> ... aaa
> ... bbb
> ... ccc
> ... '''
> >>> s
> '\naaa\nbbb\nccc\n'
> >>>
> >>> assert '''
> ... aaa
> ... bbb
> ... ccc
> ... ''' != s
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AssertionError
> >>>
>
> thus if I get some code:
>
> self.assertNotEquals('''
> aaa
> bbb
> ccc
> ''', s)
>
> I should not be pasting in the backslashes.
>
> But
>
> >>> parser.expr(s)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "<string>", line 3
> bbb
> ^
> SyntaxError: invalid syntax
> >>>
> .... suggestions on how to recognise triple-quoted strings?
>
> Apologies if I miss something obvious, my brain isn't really good for much yet.
I think you are mixing the string s with its repr-esentation in source code.
When you actually try-to-parse
self.assertNotEquals('''
aaa
bbb
ccc
''', s)
then you will at some point pass "'\naaa\nbbb\nccc'" to parser.expr()
which will succeed.
HTH and happy recovery,
Holger
_______________________________________________
[EMAIL PROTECTED]
http://codespeak.net/mailman/listinfo/pypy-dev