>>> [(x, x**2) for x in vec]
I understand the list comprehension as a whole but have forgotten the
** operator's use. Can someone please guide me.
I think this should be also mentioned in the Built-In Functions section
of the Library Reference. Probably most users do not read the Language
Reference (since the main menu says it's "for language lawyers" and yes,
it is not really fun to read).
In the explanation about pow() at
http://docs.python.org/lib/built-in-funcs.html, the notation 10**2 is
suddenly used, without explaining that it is equivalent to pow(10,2). I
think this could be improved in the docs.
-- Christoph
You're right, it's mentioned there in section 2.3.4, but the explanation
of pow() is already in section 2.1 prior to that.
So it would be nice if the paragraph explaining pow() would mention that
you can also write x**y for pow(x,y). And/or the example given in the
paragraph should say pow(10,2) instead of 10**2. Otherwise it's a bit
confusing for somebody who reads in chronological order and doesn't know
about the ** syntax (many other languages write x^y instead of x**y).
-- Christoph
The way to make this change happen is to submit a bug report with your
suggested change. See the link at the bottom of the above page to find
out how.
Kent
I know, but I wanted to see at least one person assenting before doing
so. Anyway, I took your words as assent and filed a bug report now ;-)
-- Christoph
I agree and think the "for language lawyers" should be changed to
something that encourages people to read it instead of encouraging them
to avoid it. Maybe:
"The Python language structure for everyone".
If it's hard to read and understand, then that can and should be fixed.
It probably should be moved to a position before the library reference
manual and after the tutorial. Looking over the language reference
manual will help in understanding the library reference manual I think.
Cheers,
Ron
... which was promptly rejected. Seems like the Gods of Python don't
want newbies to understand the manuals too easily, so they can have
their fun ranting why they did not RTFM, when they come here and ask
silly questions. ;-)
-- Christoph
Hm, actually that was not my point. I think the writers of the Language
Reference already did a very good job. The precise and "authoritative"
language reference covering all the subtleties and special cases will
never be fun to read. You would rather learn the use of the keywords and
the basic rules and magic attributes of the language from a good
tutorial or handbook, and look up the Language Reference really
seldomly. You can program quite well in Python without ever having
looked into the official Language Reference. Newbies should not think
they need to read it in order to start programming.
However, it is different with the Lib Reference. This is used on a daily
basis, you will often look into it, Python users are accustomed to it,
and it should invite readers to really browse and read and learn more
about the power of the batteries included. My point was that since users
are more accustomed to and prefer to use the Lib reference as their
first source of information rather than the Language reference, it
should not be reluctant to mention some things which strictly speaking
belong to the Language Reference. In some cases, it can also point to
the Lanugage Reference for the details (and it does so already).
-- Christoph
... but now it has been checked in by somebody else anyway. The Python
gods sometimes move in mysterious ways ;-)
-- Christoph
The tracker item reviewers are people, including me, with different
knowledge, viewpoints and experiences, who sometimes disagree.
Had I seen the tracker item and/or read this thread to the end before I made
that checkin, I probably wouldn't have made it... ;)
Georg
But then we would have never known that the Python gods are only people ;-)