----- Forwarded message from Ype Kingma <yk...@xs...> -----
From: Ype Kingma <yk...@xs...>
Date: Thu, 29 Mar 2001 11:49:26 +0100
To: D-Man <ds...@ri...>
-D,
>On Wed, Mar 28, 2001 at 10:19:50PM +0100, Ype Kingma wrote:
>| -D,
>|
>| >On Wed, Mar 28, 2001 at 09:21:19PM +0100, Ype Kingma wrote:
>| >|
>| >| "Robert W. Bill" wrote:
>| >| >
>| >| > assert(test(stringtest, S[1])), "String test failed"
>| >| >
>| >|
>| >| Also the assert code is a bit strange:
>| >| 'assert' is a keyword, not a function.
>| >| Leaving out one pair of brackets gives:
>| >
>| >Robert has already mentioned that his post was hasty and had several
>| >errors in it. The posted line is harder to read due to the lack of
>| >whitespace between 'assert' and '('. Anyways, just FYI, assert can
>|
>| Sorry for that, I assumed the whole history was there...
>
>No problem.
>
>| >take a 2-tuple as its only "argument"
>| >
>| >assert ( 0 , "Hello World" )
>| >
>| >is equivalent to
>| >
>| >assert 0 , "Hello World"
>| >
>| >It is quite useful when the expression, or more often, the string is
>| >too long. By using parens to create a tuple the \ prior to the
>| >newline is not necessary.
>|
>| Useful indeed. I rechecked the (python) docs on the assert statement, but
>| the tuple argument isn't mentioned there. Is there documentation
>| for it somewhere?
>
>I don't know. I have noticed that several keywords that take 2
>"arguments" (like 'raise' for example) can take a 2-tuple instead. I
>tried it with assert and it worked.
>
>Now that I think about it, I think it is actually caused by the
>lexer/parser that expressions of the form
>
><foo> , <bar>
>
>are tuples, and also
>
>( <foo> , <bar> )
>
>is the same tuple.
>
>
>I just took a look at
>
>http://www.python.org/doc/current/ref/parenthesized.html
>
>and the last paragraph seems most relevant. I guess assert and raise
>take a 2-tuple which can optionally have parenthesis or not. I use
>the parens when I want to break it over multiple lines without using
>\, but I put a space so it doesn't look like a function call.
>
>-D
It seems that this is an ambiguity in the language definition.
The syntax of assert (see previous post) does not allow '('
and ')' and it does not state that the comma introduces a tuple,
but in the last paragraph of 5.2.3 (see your URL above) it states
that a comma introduces a tuple.
I think I won't use the parenthesized form, it might break in the
future.
Could you post your evt. reply to jython-users?
Thanks in advance,
Ype
----- End forwarded message -----
|