documentation: what is "::="?
Diez B. Roggisch
deets at nospam.web.de
Mon Oct 13 17:41:32 EDT 2008
Anita Kean schrieb:
> Hello
>
> I just downloaded the new python2.6 documentation,
> full of hopes it would solve some basic mysteries for me.
> I'm new to python, so please forgive my ignorance.
> I've two questions.
>
> 1) Everywhere in the old and new documentation, the
> string of characters "::=" is used in "explaining" things - but
> I can nowhere find any stated meaning of this string.
> I've had no luck searching on it on search engines -
> and even less if I don't quote it - the search engine returns an
> error.
>
> I couldn't find one occurrence of it in the new 2.6 tutorial,
> nor in the sphinx-generated index of symbols, where "==" and
> other character strings appear.
> But for example in the reference directory, a grep on "::="
> returns many many hits,
> and the first one in simple_stmts.html (which I sort of
> hoped _would_ be simple) was (quote):
>> Simple statements¶
>>
>> Simple statements are comprised within a single logical line. Several
>> simple statements may occur on a single line separated by semicolons.
>> The syntax for simple statements is:
>> simple_stmt ::= expression_stmt
>> | assert_stmt
>> | assignment_stmt
>> | augmented_assignment_stmt
>> | pass_stmt
>> | del_stmt
>> | print_stmt
>> | return_stmt
>> | yield_stmt
>> | raise_stmt
>> | break_stmt
>> | continue_stmt
>> | import_stmt
>> | global_stmt
>> | exec_stmt
>>
>> Expression statements¶
>> ...
> (unquote)
>
> So what's the relationship between the left and right hand sides of the "::="
> string here?
http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form
> 2) There is one other symbol the Python documentation seems to have appropriated
> but never documents which I also come up against constantly, but which is never
> defined - its use of "<==>"
>
> e.g. in the os module docs
> __str__(...)
> | x.__str__() <==> str(x)
>
> (and that's all there is on __str__ in os)
>
> I'm guessing something like "if and only if" is implicated here?
It's equivalence, like in
x = 2 <==> 2*x = 4
Diez
More information about the Python-list
mailing list