Python reference

  • Thread starter Matthew Thorley
  • Start date
M

Matthew Thorley

John said:
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
 
R

Reiner Block

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
 
J

John fabiani

Reiner said:
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
 
C

Cameron Laird

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.
 
T

Timo Virkkala

Reiner said:
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.
 
R

Reiner Block

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
 
H

Heiko Wundram

Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:
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.
 
H

Heiko Wundram

Am Donnerstag, 3. Juni 2004 21:55 schrieb Reiner Block:

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.
 
G

Grant Edwards

-----------------------------------------------------------------------
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.
 
A

Antonio Manuel Dias

Hello.

Reiner said:
import os
os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')

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,
 
C

Christos TZOTZIOY Georgiou

.
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...
 
N

Neil Benn

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 : (e-mail address removed)
Cenix Website : http://www.cenix-bioscience.com
 
F

flupke

"Heiko Wundram" <[email protected]> schreef in bericht
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 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
 
R

Reiner Block

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
 
D

Doug Holton

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

Heiko Wundram

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.
 
H

Heiko Wundram

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.
 
R

Reiner Block

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top