473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Python reference

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
27 2350
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
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
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
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
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
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
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
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
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
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
"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
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
> 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

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
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
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
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
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
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
In article <2i************@uni-berlin.de>,
Reiner Block <re**********@bisoft.de> wrote:
Jul 18 '05 #21

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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
11
by: Magnus Lycka | last post by:
While the official Python Tutorial has served its purpose well, keeping it up to date is hardly anyones top priority, and there are others who passionately create really good Python tutorials on...
0
by: nejucomo | last post by:
Hi folks, Quick Synopsis: A test script demonstrates a memory leak when I use pythonic extensions of my builtin types, but if I use the builtin types themselves there is no memory leak. ...
0
by: devito | last post by:
hi there, for some days i try to build the boost.python tutorial "hello world" without bjam on winxp by using mingw. so i wrote a *.bat-file like the following: // --- snip...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.