473,837 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

documentation: what is "::="?

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.ht ml (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_assig nment_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?

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?
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?

Are "::=" and "<==>" documented anywhere in the python docs?
Thanks
Anita
Oct 13 '08 #1
7 1424
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.ht ml (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_assig nment_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/Extende...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
Oct 13 '08 #2
On Oct 13, 5:33 pm, Anita Kean <ak...@paradise .net.nzwrote:
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.ht ml (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_assig nment_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?

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 isnever
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?
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.pat h)
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?

Are "::=" and "<==>" documented anywhere in the python docs?
Neither of these is a valid Python operator. '::=' is Backus-Naur Form
(BNF) metasyntax [1]; it's a general syntax to express context free
grammars. "<==>" typically denotes mathematical equivalence; it is
used informally in the docs to express that two expression are
equivalent.

I can't tell why you get an error on str(sys.path); it works fine
here. Something is probably wrong with your installation or locale
configuration.

George

[1] http://en.wikipedia.org/wiki/Backus-Naur_form
Oct 13 '08 #3
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.pat h)
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).

Oct 14 '08 #4
Anita Kean wrote:
I'm guessing something like "if and only if" is implicated here?
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.pat h)
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?
Before these three commands you have probably executed

from locale import *

This has imported the locale.str() function that now shadows the builtin
str(). Had you imported locale with

import locale

(which is the recommended approach unless you're really know what you're
doing) you would have gained access to the functions in the module as, e.
g.

locale.str(...)

and still be able to access the built-ins in the usual way.

Peter
Oct 14 '08 #5
In message <gd************ *@news.t-online.com>, Peter Otten wrote:
... you have probably executed

from locale import *

This has imported the locale.str() function that now shadows the builtin
str().
One of many reasons not to use wildcard imports. :)
Oct 14 '08 #6
On 2008-10-14, Peter Otten <__*******@web. dewrote:
Anita Kean wrote:
>>...
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:
>>>
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
...
Before these three commands you have probably executed

from locale import *

This has imported the locale.str() function that now shadows the builtin
str(). Had you imported locale with

import locale

(which is the recommended approach unless you're really know what you're
doing) you would have gained access to the functions in the module as, e.
g.

locale.str(...)

and still be able to access the built-ins in the usual way.
That's correct.
I found that line in my .pystartup file yesterday and commenting it out
solved the problem.
I recall when I initially started using python, scrambling to find
some way to enable persistent history across sessions (something I
was used to in many other apis) and copying some suggested .pystartup
to enable this.
It solved the problem at the time, only to create others.

Thanks Peter.

And thanks everyone for the pointers on ::=
I'm still curious about why isn't it documented if it's used so much
in the documentation and is known by another name.
Obviously Wikipedia seems to think it's not totally obvious if they
have an entry.
It sure would have made the python docs easier to read!

Anita
Oct 14 '08 #7
In message <sl************ ******@localhos t.localdomain>, Anita Kean wrote:
I'm still curious about why isn't ["::="] documented ...
It is <http://docs.python.org/reference/introduction.ht ml#id2>.
Oct 15 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
7037
by: Noam Raphael | last post by:
Hello, I thought about a new Python feature. Please tell me what you think about it. Say you want to write a base class with some unimplemented methods, that subclasses must implement (or maybe even just declare an interface, with no methods implemented). Right now, you don't really have a way to do it. You can leave the methods with a "pass", or raise a NotImplementedError, but even in the best solution that I know of,
5
3438
by: BoonHead, The Lost Philosopher | last post by:
Does anyone know how to implement internal interface documentation for functions and parameters? I found a similair thing for proerties. For properties I found something like: <System.ComponentModal.Description("This property sets aars!")> Property Aars() As Boolean '...Property body... End Property
9
6667
by: PG | last post by:
Hi gurus, I have AIX visual age C++ compiler version 5.0.2.3. I have a simple hello world program that gives compilation errors. Any help will be appreciated. Thanks PG ***test.cpp**** #include <stdio.h>
3
2485
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going wrong? I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains: //**************************** //**************************** Compiler output starts *********** cd /home/red/tmp/testprogs/
11
24096
by: Matt Kruse | last post by:
This is a common requirement - "freeze panes" in a table, so that some header rows and some columns on the left are frozen while the body content scrolls. This makes large tables more usable on screen. There are a number of solutions available. For example, http://www.litotes.demon.co.uk/example_scripts/tableScroll.html I'm just wondering if anyone knows of a "latest and greatest" script to solve this problem. My requirement at the...
2
1756
by: Kalle Anke | last post by:
I'm confused of how I should document my code, I've always liked being able to document my code directly in my source file and then to use some tool to extract the documentation to some other format. My problem with Python is that there are so many tools and formats ... I don't know which one I should use. I've tried to figure out if there is one that is the "de-facto standard" but ... Could someone advice me on what format/tool I...
1
1621
by: Burkhard Perkens-Golomb | last post by:
Hi, I've a question about XML documentation of overridding methods and methods implementing an interface declaration: These methods are normally documented in the base class or interface. So I don't want to write new documentation when overriding or implementing. But if I leave out documentation and compile my assembly with "/doc" the compiler warns me about missing documentation. How can I tell the compiler that these methods don't...
28
3014
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. Ruby has ... an issue with docs. That is to say, there are almost none. Well, actually, there are some. For example, the "PickAxe" book (google it), and "Why's" Poignant Guide. But there's a disturbing lack of *built-in* docs for Ruby. Now, the...
7
1267
by: david.deridder | last post by:
Hi, I would like to specify in my XSD that the "Documentation" element can be added everywhere in the XML document. A bit like the xs:documentation node. How can i declare this in my XSD? An example <a>
4
4823
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I don't really understand how these namespace work in xml. (I am however aware of what problems namespaces solve) I'm not even sure if the provided xsd is 'common' practice, although it validates correctly. So I'll describe exactly what I've...
0
9691
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10891
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10582
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7009
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.