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
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
Cameron Laird <cla...@phaseit.net>
Business: http://www.Phaseit.net
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
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 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
> -----------------------------------------------------------------------
> 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
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','neitherexistant')
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.
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 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...
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.
>In article <2i96n6F...@uni-berlin.de>,
>Reiner Block <reiner...@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. :-(
.
>When you provide more description about how <URL:
>http://docs.python.org/lib/lib.html > is "bad",
>then others will understand better what you seek,
>and will be able to help you find "a really good
>Python reference" more accurately and efficiently.
Even better, if provided with the "why" it is "bad", others might be
able to improve the current documentation...
--
TZOTZIOY, I speak England very best,
"I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses
>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...
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
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
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. :-(
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"
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.
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.
> 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. :-)
> 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
> 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
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
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
http://starship.python.net/crew/theller/pyhelp.cgi
--
WT
> 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
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
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.
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
> 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 :) )
Before "search" people were required to understand and structure their thoughts in some authority's hierarchical structure. While hierarchy and structure are of great value, being able to slice through it with a powerful search function is empowering.
Programmers are required to absorb, work in, and develop structure, so maybe the absence of search is not found too stinging, but being able to rely on it is as freeing as being able to create your own objects (in my opinion).
We should expect search to become the dominant information retrieval method in the future. Oh. It already is. So much for my soothsaying!
Python documentation is pretty good, I think; but it would save me time if I could efficiently search it all.
Eric
Of course
I could be wrong
Some of the Python books are head and shoulders above the norm. Hint, try O'Reilly: [http://tinyurl.com/3ylqo]
> 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.
"Library reference"
<http://docs.python.org/lib/lib.html>
Strings are a built-in sequence type, so: "2.3.6 Sequence Types"
<http://docs.python.org/lib/typesseq.html>
At the bottom is a link to "2.3.6.1 String Methods"
<http://docs.python.org/lib/string-methods.html>
The only "problem" I see is to remember strings are sequences, which is not
something everybody new to Python will think about immediately.
Maybe it would help if the "contents" on the front page would show 4 levels
of headers instead of 3 levels now?
--
JanC
"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9