documentation: what is "::="?

Terry Reedy tjreedy at udel.edu
Mon Oct 13 19:59:41 EDT 2008


Anita Kean wrote:
>
> 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.

Read Reference manual introductin notation:
The descriptions of lexical analysis and syntax use a modified BNF 
grammar notation. This uses the following style of definition:

name      ::=  lc_letter (lc_letter | "_")*
lc_letter ::=  "a"..."z"

The first line says that a name is an lc_letter followed by a sequence 
of zero or more lc_letters and underscores. An lc_letter in turn is any 
of the single characters 'a' through 'z'. (This rule is actually adhered 
to for the names defined in lexical and grammar rules in this document.)

...


> I'm guessing something like "if and only if" is implicated here?

yes

> But for example, if I import the sys module and perform the following three 
> commands,
>         print sys.path
>         sys.path.__str__()
>         str(sys.path)
> 
> the first two give me the python path, and the last reports an error:
>>>>> str(sys.path)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "/usr/lib/python2.5/locale.py", line 244, in str
>>     return format("%.12g", val)
>>   File "/usr/lib/python2.5/locale.py", line 147, in format
>>     formatted = percent % value
>> TypeError: float argument required
>>
> What is it I'm not understanding here?

You should include the data that gives you such puzzling output ;-).
What did print sys.path produce?
Just typing sys.path at >>> should have the same effect as str(sys.path).




More information about the Python-list mailing list