By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,895 Members | 1,753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,895 IT Pros & Developers. It's quick & easy.

Python reference

P: n/a
Hi,

does anybody knows a really good Python reference? It is not the matter if it
is online or a book, if it is in english or german. Because the official one
from www.python.org is really bad. :-(
Referencegreetings

Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #1
Share this Question
Share on Google+
27 Replies


P: n/a
Reiner Block wrote:
Hi,

does anybody knows a really good Python reference? It is not the matter if it
is online or a book, if it is in english or german. Because the official one
from www.python.org is really bad. :-(
Referencegreetings

Reiner

Try O'Reilly books.
John
Jul 18 '05 #2

P: n/a
John fabiani wrote:
Reiner Block wrote:
Hi,

does anybody knows a really good Python reference? It is not the
matter if it
is online or a book, if it is in english or german. Because the
official one
from www.python.org is really bad. :-(

Referencegreetings

Reiner


Try O'Reilly books.
John


Such as:
Learning Python by Lutz and Asher
Programming Python by Lutz
Python Cookbook by Martelli and Asher
Python Standard Library by Fredrick Lundh

When I was learning python 'Learning python' was what I read most. Now I
basicaly just use Python Standard Lib (probably my favorite) and
Programming Python. I also got a copy of Text Processing in Python by
David Mertz which is really good for text processing but kinda a heavy read.

Another book that I haven't read is Python Programming Patterns

As for online resources the Python Quick Reference is very helpful.
http://rgruet.free.fr/PQR2.3.html

cheers
-matthew
Jul 18 '05 #3

P: n/a
In article <2i************@uni-berlin.de>,
Reiner Block <re**********@bisoft.de> wrote:
Hi,

does anybody knows a really good Python reference? It is not the matter if it
is online or a book, if it is in english or german. Because the official one
from www.python.org is really bad. :-(

Jul 18 '05 #4

P: n/a
Reiner Block wrote:
does anybody knows a really good Python reference? It is not the matter if it
is online or a book, if it is in english or german. Because the official one
from www.python.org is really bad. :-(


It would be very helpful if you could elaborate on why you think the
official one is bad. It's very easy to improve on something, if one knows
what's wrong with it.

I've always managed pretty well with the tutorial and the library reference
on the official site. If there's something there I don't quite understand, I
either ask here, or take a quick look at the sources.

--
WT
Jul 18 '05 #5

P: n/a
Hi,

sorry, my question was not detailed enough. It is not Python itself, it is the
library documentation. So e.g. spawnlp is described with the header
"spawnlp(mode,file,...)". In the example later you can see
-----------------------------------------------------------------------
import os
os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
-----------------------------------------------------------------------
There is no further explaination why there are suddenly two times 'cp'! The
first says the first parameter is the mode like P_WAIT or P_NOWAITE. That's
clear. But the second should be the program to start and the third...? :-(

It is not clear why the 2nd and 3rd parameter are the same.

HTH
Searching greetings

Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #6

P: n/a
Hello.

Reiner Block wrote:
import os
os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
-----------------------------------------------------------------------
The
first says the first parameter is the mode like P_WAIT or P_NOWAITE. That's
clear. But the second should be the program to start and the third...? :-(
From the python library reference:

"""
The "l" variants are perhaps the easiest to work with if the number of
parameters is fixed when the code is written; the individual parameters
simply become additional parameters to the spawnl*() functions.
"""
It is not clear why the 2nd and 3rd parameter are the same.


"""
In either case, the arguments to the child process must start with the
name of the command being run.
"""

Cumps,

--
Antonio Manuel Dias
Jul 18 '05 #7

P: n/a
On 2004-06-03, Reiner Block <re**********@bisoft.de> wrote:
-----------------------------------------------------------------------
import os
os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
-----------------------------------------------------------------------
There is no further explaination why there are suddenly two times 'cp'! The
first says the first parameter is the mode like P_WAIT or P_NOWAITE. That's
clear. But the second should be the program to start and the third...? :-(

It is not clear why the 2nd and 3rd parameter are the same.


The 2nd parameter is the filename of the program to be
executed.

The 3rd parameter is the value of the first argument to be
passed to that program.

It is traditional on Unix systems to pass the program's name to
it as its first parameter. Some programs will behave
differently if different names are passed as that first
parameter -- allowing a single executable file to take the
place of several (usually slightly) different programs by
simply changing its name.

--
Grant Edwards grante Yow! RELATIVES!!
at
visi.com
Jul 18 '05 #8

P: n/a
Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:
-----------------------------------------------------------------------
import os
os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')
-----------------------------------------------------------------------


First and second parameter are clear to you, you say. Okay, let's start from
there: third parameter is the first parameter the program gets to see. What
is the first parameter of a program (sys.argv[0])? That's the program name!
Fourth parameter, and fifth should be clear, anyhow.

Try this:

os.spawnlp(os.P_WAIT,'cp','gugu','nonexistant','ne itherexistant')

The output you'll see on the console is:

gugu: Aufruf von stat für ,,nonexistant" nicht möglich: Datei oder Verzeichnis
nicht gefunden

So, cp does as it should, the program name which is output (in case you called
a symlink or something, it can reference you to the symlink, and doesn't
always print cp) is the first parameter to the program we passed in.

HTH!

Heiko.

Jul 18 '05 #9

P: n/a
Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:
[snip]


btw... looking at your resumé, I find it quite hard to believe you've never
had to call exec*() in another language before... ;) Calling exec() in C
takes the same arguments, first argument: program name, and then the rest...

Anyway, hope this clears things up!

Oh, and I just wanted to say that I find the Python documentation fantasticas
it is! I don't want to have another PHP-newbie like
spelling-out-every-detail-but-don't-find-what-you're-looking-for kind of
documentation, but just as Python applauds to every programmers common sense,
so should the documentation... And if there's any doubt, looking up man 2
exec should've gotten you there too...

I don't say I don't have any criticism about some other parts (like the
Extending and Embedding manual), but overall it's just fine as it is...

Heiko.

Jul 18 '05 #10

P: n/a
On Thu, 03 Jun 2004 18:18:49 -0000, rumours say that cl****@lairds.com
(Cameron Laird) might have written:
In article <2i************@uni-berlin.de>,
Reiner Block <re**********@bisoft.de> wrote:
Hi,

does anybody knows a really good Python reference? It is not the matter if it
is online or a book, if it is in english or german. Because the official one
from www.python.org is really bad. :-(

Jul 18 '05 #11

P: n/a
"Heiko Wundram" <he*****@ceosg.de> schreef in bericht
news:ma*************************************@pytho n.org...
Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:
[snip]
Oh, and I just wanted to say that I find the Python documentation fantastic asit is! I don't want to have another PHP-newbie like
spelling-out-every-detail-but-don't-find-what-you're-looking-for kind of
documentation, but just as Python applauds to every programmers common sense,so should the documentation... And if there's any doubt, looking up man 2
exec should've gotten you there too...


I don't agree. The online reference of Php is far easier to search than the
Python
reference. There's no excuse for not having a decent search function.
period.
That's what i hate about the Java docs too. No search capability.
Php doc rocks because of that (at least for me :) )

Benedict
Jul 18 '05 #12

P: n/a
Hello,

I've kept quiet about the Python documentation up till now but
after some experience, I have a few comments - I do hope that they
help. Firstly my experience : my main language is Java (also VB,
Pascal, small amount of C/C++, C#) but I've learnt Python after coming
to a new job.
Generally the documentation is good, remembering that this is an
open-source project and most people hate doing documentation there is a
lot of good documentation available and the books are pretty good.
However there problem that I've had most frequently is actually finding
the information I need (personally I don't like the 'everyone
contribute' type of documentation as there can be a lot of clutter and
repetition). I think the module index is OK but there are fundamental
things missing. For example, I have a String object and want to find a
method that can give me a starts with. Before people say I can type
dir("IT'S OBVIOUS") or simply just guess (is it startswith, starts_with,
StartsWith, etc - that's before I get to the parameters), let's assume
that I'm coming from a language without an interepter - say Java, C#,
VB, C/C++, Pascal, etc.

So, following behavior of docs I would expect from other language's,
I go to the module index and it gives me the definitions for all the
functions for the String 'module' but not the String 'object'. So,
thinking - OK, it a could be in the language ('library') reference, I'll
look in there - I know that a String is a sequence so it may have a
reference there but I get a link back to the string module.

(I know there are historical things surrounding this but again a
beginner in Python would not know this)

Personally I now know that it can be worked out by persevering and
so on - so I don't need this information anymore because I know it and I
can use the docs installed on a win32 python dist (which has searching)
BUT a beginner will instinctively apply the knowledge they have from
other areas and look on python.org.

For an example of what I'm thinking about, take a look at the J2SE
docs :-

http://java.sun.com/j2se/1.4.2/docs/api/index.html

I hope that this is taken in a spirit of _constructive_ criticism,
AFAIK pyDoc can do this type of thing already - would it be an idea to
put a pyDoc type language reference on the python.org webpage?

Obviously your behavior will be different if you are coming from a
different language but I've never used PHP, Perl, etc - I've come at
this from a different direction.

Cheers,

Neil

--

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
Jul 18 '05 #13

P: n/a
> btw... looking at your resumé, I find it quite hard to believe you've never
had to call exec*() in another language before... ;) Calling exec() in C
takes the same arguments, first argument: program name, and then the rest...
Of course I did but if I right remember e.g. DosExec, WinExec and WinExecN (I
hope I remember the functions names in a right way ;-) ) don't needed the
process name a second time, isn't it?
Anyway, hope this clears things up!
Yes, it does. :-)
Oh, and I just wanted to say that I find the Python documentation fantastic
as it is! I don't want to have another PHP-newbie like
spelling-out-every-detail-but-don't-find-what-you're-looking-for kind of
documentation, but just as Python applauds to every programmers common sense,
so should the documentation... And if there's any doubt, looking up man 2
exec should've gotten you there too...

Perhaps a few more examples. You know: Sometimes it is a small detail that you
forgot and you are searching, and searching, and searching... ;-)

E.g. at the moment I'm working on capisuite for Linux and want to change and
enhance many things. One is the sending of emails with a fax or voice as an
attachment because at the moment it is just a call of sendmail. But I've no
sendmail and I CAN NOT install it. So I have to see how to take the
email.MIME... and send it by the SMTP module. :-)

But first I've to see how to get eric3 again running. Because I installed the
current snapshot but it has a problem inside the DebugClientBase.py and
DebugBase.py. There are many changes in comparision to version 3.4.2. And
3.4.2 crashes wenn I called Run the script. :-(

Searching greetings

Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #14

P: n/a

Here's an easy wrapper for os.spawn that lessens the confusion:

import os

def run (program, *args):
"Run external program, wait til it quits, and return the exit code"
spawn = os.spawnvp #not available on windows though
if os.name == "nt": spawn = os.spawnv
return spawn(os.P_WAIT, program, (program,) + args)

def start (program, *args):
"Start an external program and return immediately, returning proc id"
spawn = os.spawnvp #not available on windows though
if os.name == "nt": spawn = os.spawnv
return spawn(os.P_NOWAIT, program, (program,) + args)

#example:
errcode = run('cp','index.html','index2.html')
if errcode == 0: #no error
pid = start('cp','index2.html','index3.html')
else:
print "error finding or copying the index.html file"
Jul 18 '05 #15

P: n/a
Am Freitag, 4. Juni 2004 12:09 schrieb Reiner Block:
Of course I did but if I right remember e.g. DosExec, WinExec and WinExecN
(I hope I remember the functions names in a right way ;-) ) don't needed
the process name a second time, isn't it?
I've never done any Windows programming so far (under DOS, using TC++ 3.0
exec() took the program name as first parameter, I'm pretty sure of that...),
so I don't know... ;)
But first I've to see how to get eric3 again running. Because I installed
the current snapshot but it has a problem inside the DebugClientBase.py and
DebugBase.py. There are many changes in comparision to version 3.4.2. And
3.4.2 crashes wenn I called Run the script. :-(


Hmm... Why not work with emacs? I actually like the emacs Python mode. It's
pretty sophisticated, and does all I need to program in Python. I've yet to
see eric (it's installed, but I've never used it), but I've never felt the
need for more than the Python-mode of emacs.

Heiko.

Jul 18 '05 #16

P: n/a
Am Freitag, 4. Juni 2004 11:18 schrieb flupke:
I don't agree. The online reference of Php is far easier to search than the
Python
reference. There's no excuse for not having a decent search function.
period.
That's what i hate about the Java docs too. No search capability.
Php doc rocks because of that (at least for me :) )


Searching in the Python documentation (or rather on the website):

1) Open www.google.com
2) Enter: site:www.python.org <keyword(s)>
3) Look at the results. ;)

Heiko.

Jul 18 '05 #17

P: n/a
Hi Heiko,
Hmm... Why not work with emacs? I actually like the emacs Python mode. It's
pretty sophisticated, and does all I need to program in Python. I've yet to
see eric (it's installed, but I've never used it), but I've never felt the
need for more than the Python-mode of emacs.

at the moment I really don't want to learn such a high sophisticated editor
like emacs. :-)
Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #18

P: n/a
Hi Heiko,
1) Open www.google.com
2) Enter: site:www.python.org <keyword(s)>
3) Look at the results. ;)

and you'll get 10 result pages. ;-)

Learning greetings

Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #19

P: n/a
Reiner Block <re**********@bisoft.de> writes:
Hi Heiko,
1) Open www.google.com
2) Enter: site:www.python.org <keyword(s)>
3) Look at the results. ;)

and you'll get 10 result pages. ;-)


You could also try
site:docs.python.org <keyword(s)>
instead.

And to find keywords in the index of the Python docs, you could use
<http://starship.python.net/crew/theller/pyhelp.cgi>

Thomas
Jul 18 '05 #20

P: n/a
In article <2i************@uni-berlin.de>,
Reiner Block <re**********@bisoft.de> wrote:
Jul 18 '05 #21

P: n/a

"Neil Benn" <be**@cenix-bioscience.com> wrote in message
news:40**************@cenix-bioscience.com...
Generally the documentation is good, remembering that this is an
open-source project and most people hate doing documentation there is a
lot of good documentation available and the books are pretty good.
and remembering that the references are voluteer work...
However there problem that I've had most frequently is actually finding
the information I need (personally I don't like the 'everyone
contribute' type of documentation as there can be a lot of clutter and
repetition). I think the module index is OK but there are fundamental
things missing. For example, I have a String object and want to find a
method that can give me a starts with. Before people say I can type
dir("IT'S OBVIOUS") or simply just guess (is it startswith, starts_with,
StartsWith, etc - that's before I get to the parameters), let's assume
that I'm coming from a language without an interepter - say Java, C#,
VB, C/C++, Pascal, etc.


If you have a specific suggestion, submit a SourceForge tracker item with
category documentation. If you have an actual patch to the LaTex source,
its a patch item. If it is pretty clearly a flaw, make a bug item. If a
suggestion for improvement but not obviously a bug, make an RFE item. Many
improvements to the official docs have come from such submissions!

In this case, it appears that the list you wanted in in 2.3.6.1 String
Methods which you find under 2.3.6 Sequence Types, etc. In the interactive
interpreter, help(str) also gives a list which eventually shows
| startswith(...)
| S.startswith(prefix[, start[, end]]) -> int
|
| Return 1 if S starts with the specified prefix, otherwise return 0.
With
| optional start, test S beginning at that position. With optional
end, stop
| comparing S at that position.

Terry J. Reedy


Jul 18 '05 #22

P: n/a
> I hope that this is taken in a spirit of _constructive_ criticism,
AFAIK pyDoc can do this type of thing already - would it be an idea to
put a pyDoc type language reference on the python.org webpage?


How about http://pydoc.org/

And then there's always http://starship.python.net/crew/theller/pyhelp.cgi
You can give it a word to search through the python documentation.

--
WT
Jul 18 '05 #23

P: n/a
flupke wrote:
There's no excuse for not having a decent search function. period.


http://starship.python.net/crew/theller/pyhelp.cgi

--
WT
Jul 18 '05 #24

P: n/a
Hi Thomas,
And to find keywords in the index of the Python docs, you could use
<http://starship.python.net/crew/theller/pyhelp.cgi>

<ironic>really great this documentation.</ironic> I'm searching and searching
for two possibilities: test if a string is a number (integer) or to strip
leading and trailing blanks. But it is impossible to find in the documentation
how to do it. :-( Really: I never saw a worse docu as this one.

Angry greetings

Reiner
--
"Was immer du tun kannst oder erträumst zu können, beginne es jetzt."
von: Johann Wolfgang von Goethe (1749-1832)

Reiner Block
http://www.bisoft.de

Jul 18 '05 #25

P: n/a
Reiner Block wrote:
Hi Thomas,

And to find keywords in the index of the Python docs, you could use
<http://starship.python.net/crew/theller/pyhelp.cgi>
<ironic>really great this documentation.</ironic> I'm searching and searching
for two possibilities: test if a string is a number (integer) or to strip
leading and trailing blanks. But it is impossible to find in the documentation
how to do it. :-( Really: I never saw a worse docu as this one.


Search for "strip" will give you the second. The other is more difficult
to find like this - its isdigit. But both can be found easily be saying
help(str) from the Python prompt.
The problem is that you've misunderstood the purpose of this web page.
Angry greetings


There's no need to be angry! He made a page that other people can find
useful, and you didn't find it useful. He didn't set out to harm you...

David
Jul 18 '05 #26

P: n/a
Am Freitag, 4. Juni 2004 22:07 schrieb Reiner Block:
<ironic>really great this documentation.</ironic> I'm searching and
searching for two possibilities: test if a string is a number (integer) or
to strip leading and trailing blanks. But it is impossible to find in the
documentation how to do it. :-( Really: I never saw a worse docu as this
one.


I don't really know how you're looking for what you need... Stripping leading
and trailing blanks is something that has to do with string manipulation. Go
and check: Library Reference -> String Type, and you'll soon find
str.strip().

About testing whether something is an integer: As always in Python, try to do
what you're doing, and test whether it succeeds.

y = "123a"
try:
x = int(y)
except ValueError:
print "Not a number."

HTH!

Heiko.

Jul 18 '05 #27

P: n/a

"Timo Virkkala" <a@a.invalid> schreef in bericht
news:bB***************@read3.inet.fi...
flupke wrote:
There's no excuse for not having a decent search function. period.


http://starship.python.net/crew/theller/pyhelp.cgi

--
WT


This indeed helps a lot. I've entered the search key file to simulate
what i would do if i wanted to know how to write to a file but didn't
know where to start. (This is actually one of the cases where the
Python docs are very clear and the info is easy to find). Then i
find a lot of usefull info.
Now this should be part of the main python site!

Thanks
Jul 18 '05 #28

This discussion thread is closed

Replies have been disabled for this discussion.