Re: Question regarding __new__

2007-03-23 Thread Gabriel Genellina
En Thu, 22 Mar 2007 13:19:52 -0300, Frank Benkstein  
<[EMAIL PROTECTED]> escribió:

> Yet [1] says: "[...] some rules for __new__: [...] If you return an
> object of a different class, its __init__ method will be called."

That was true at that time (2.2 initial), but not now. See  
http://www.python.org/sf/537450
Revision 26220 - Modified Sat Apr 6 01:05:01 2002 UTC (4 years, 11 months  
ago) by gvanrossum
- Changed new-style class instantiation so that when C's __new__
   method returns something that's not a C instance, its __init__ is
   not called.  [SF bug #537450]

The documentation should be updated to reflect this change.

> Am I missing something? Is this documented somewhere else?

See http://docs.python.org/ref/customization.html

> Also it
> would be nice if someone could point me to the function that implements
> this in C. I didn't find anything in object.c or typeobject.c.

It's in typeobject.c, function type_call

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with time

2007-03-23 Thread ian

"Steve Holden" <[EMAIL PROTECTED]> a écrit dans le message de news:
[EMAIL PROTECTED]
> import time
> import datetime
>
> dbtd = 
> h, m, s = time.localtime()[3:6]
> timenow = s + (60 * (m + 60 * h))

Look like ok, thanks all :)


-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Idiom for running compiled python scripts?

2007-03-23 Thread Gerard Flanagan
On Mar 23, 8:30 am, Mark <[EMAIL PROTECTED]> wrote:
>
> Of course I am not deleting the sources. In fact, I am also talking
> about python scripts being called from shell scripts.

There's a nice recipe in Python Cookbook (Martelli et al.) for this.
It involves zipping your .pyc files and adding a shell stub. Never
used it before but I'm going to need something similar in the near
future, probably with a text templating system such as Cheetah
(www.cheetahtemplate.org).

HTH

Gerard



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to receive a FILE* from Python under MinGW?

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 01:47:22 -0300, John Pye <[EMAIL PROTECTED]> escribió:

> On Mar 23, 3:33 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> import msvcrt
>> fh = msvcrt.get_osfhandle(f.fileno())
> ..
>> example.filetest(fh)
>> f.close()
>
> Cool, that looks great, Gabriel.
>
> But is there any way I can hide the get_osfhandle call inside my
> Python module? That way I wouldn't need to request end users to make
> contorted 'if platform.system()=="Windows"' calls everywhere.
>
> Maybe this *is* workable, after all :-)

I can think of two ways:

- Define a Python function to do that, and test the platform just there.  
Something like that:

def exportable_file(f):
   if we_are_working_on_windows:
 import msvcrt
 return msvcrt.get_osfhandle(f.fileno())
   else:
 return f

And replace all places where a Python file goes into a C extension, with  
exportable_file(f)

- Define your own file class, inheriting from file, and store that handle  
as an attribute

class my_file_class(file):
   def __init__(self, name, mode="r", buffering=-1):
 file.__init__(self, name, mode, buffering)
 self.handle = msvcrt.get_osfhandle(self.fileno())

But I've not checked this; I'm not sure if file creation always goes thru  
this __init__; I assume the file will never change its FILE struct (f_fp  
member) (uhm, is there any way to re-open a file?). Perhaps this approach  
has many assumptions to be usable at all - uh, forget it.


-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python on window

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 04:25:52 -0300, sandeep patil <[EMAIL PROTECTED]>  
escribió:

> i have install python on window xp os.
> C:/program files/python
>
> i have done print program it working but .py can't  working
>  help me  to how i will execute this file this file where i will save
> it.
> path execution how .
> tell me about any envorment veriable in python to set before python
> editor run,it path. etc

You don't need to set any environment variable to run Python. (Perhaps  
PYTHONPATH, but *only* if you put modules into non standard places)

 import posix
>
> Traceback (most recent call last):
>   File "", line 1, in 
> import posix
> ImportError: No module named posix

That's ok: there is no module named "posix" on Windows, it is only  
available on Unix systems.

I've rearranged a bit your example. Write the following into a file named  
test.py - use whatever editor you like (even notepad):

---begin file test.py---
def invert(table):
 index = {}
 for key in table:
 value = table[key]
 if not index.has_key(value):
 index[value] = []
 index[value].append(key)
 return index

phonebook = {'sandeep':9325, 'amit':9822, 'anand':9890, 'titu': 9325}
print "Phonebook", phonebook

inverted_phonebook = invert(phonebook)
print "Inverted phonebook", inverted_phonebook
---end file test.py---

Then open a console window, change to the same directory where you saved  
test.py, and execute:

python test.py

You should get:

Phonebook {'titu': 9325, 'amit': 9822, 'anand': 9890, 'sandeep': 9325}
Inverted phonebook {9890: ['anand'], 9325: ['titu', 'sandeep'], 9822:  
['amit']}

There are plenty of tutorials about Python. A good book -among others- is  
"Dive into Python"; you can buy the book, read it online, or even download  
it from http://www.diveintopython.org/

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a non-root daemon process

2007-03-23 Thread Leo Kislov
On Mar 22, 11:19 pm, Ben Finney <[EMAIL PROTECTED]> wrote:
> Howdy all,
>
> For making a Python program calve off an independent daemon process of
> itself, I found Carl J. Schroeder's recipe in the ASPN Python Cookbook.
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731>
>
> This is a thorough approach, and I'm cribbing a simpler process from
> this example. One thing that strikes me is that the algorithm seems to
> depend on running the program as the root user.
>
> import os
>
> def become_daemon():
> pid = os.fork()
> if pid == 0:
> # This is the child of the fork
>
> # Become a process leader of a new process group
> os.setsid()
>
> # Fork again and exit this parent
> pid = os.fork()
> if pid == 0:
> # This is the child of the second fork -- the running process.
> pass
> else:
> # This is the parent of the second fork
> # Exit to prevent zombie process
> os._exit(0)
> else:
> # This is the parent of the fork
> os._exit(0)
>
> become_daemon()
> # Continue with the program
>
> The double-fork seems to be to:
>   - Allow the first forked child to start a new process group
>   - Allow the second forked child to be orphaned immediately
>
> The problem I'm having is that 'os.setsid()' fails with 'OSError:
> [Errno 1] Operation not permitted' unless I run the program as the
> root user. This isn't a program that I want necessarily running as
> root.

It works for me. I mean your program above produces no exceptions for
me on Debian 3.1 python2.4

> What does the 'os.setsid()' gain me?

It dettaches you from terminal. It means you won't receive signals
from terminal for sure. Like SIGINT and SIGHUP, but there are maybe
other.

> How can I get that without being
> the root user?

Maybe you can go over the list of all possible signals from the
terminal and notify kernel that you want to ignore them. Sounds
similar to dettaching from the terminal, but maybe there some
differences. But the fact that os.setsid fails for you is weird
anyway.

  -- Leo.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how can I invoke a Java code?

2007-03-23 Thread Laurent Pointal
momobear a écrit :
> A friend of my write a Java program, and I want use it in my python
> program as a module. I searched the topic in Google and find maybe the
> better way is use GCJ to compile it. Is there any other way for me?
> the simple and speediness choice the better. thanks. 

See my links:
http://www.limsi.fr/Individu/pointal/python.html#liens-intautlang-java

You can look at
* Jython
* JPype
* JEP
* java2python



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python on window

2007-03-23 Thread jwelby
On Mar 23, 7:25 am, "sandeep patil" <[EMAIL PROTECTED]> wrote:
> i have install python on window xp os.
> C:/program files/python
>
> i have done print program it working but .py can't  working
>  help me  to how i will execute this file this file where i will save
> it.
> path execution how .
> tell me about any envorment veriable in python to set before python
> editor run,it path. etc
> 
>
> >>> print ' sandeep patil'
>  sandeep patil
> >>> print ' sandeep "bhagwan " patil ,msc. java j2ee developer"
>
> SyntaxError: EOL while scanning single-quoted string>>> print ' sandeep 
> "bhagwan " patil ,msc. java j2ee developer'
>
>  sandeep "bhagwan " patil ,msc. java j2ee developer
>
> >>> import posix
>
> Traceback (most recent call last):
>   File "", line 1, in 
> import posix
> ImportError: No module named posix
>
> >>> phonebook = {'sandeep':9325,'amit':9822,'anand':9890}
> >>> phonebook = {'titu':9423,'dadu':9422,'giri':9326}
> >>> inverted_phonebook=invert(phonebook)
>
> Traceback (most recent call last):
>   File "", line 1, in 
> inverted_phonebook=invert(phonebook)
> NameError: name 'invert' is not defined>>> def invert(table):
>
> index={}
> for key in table.key():
> value=table[key]
> if not index.has_key(value):
> index[value]=[]
> index[value].append(key)
> return index
> 

Hi Sandeep.

As you are working with Python on Windows, I would suggest that you
install the Python for Windows extensions from here:

http://sourceforge.net/project/showfiles.php?group_id=78018

It includes a very good application called PythonWin. Once installed,
PythonWin will be available under Python in your Start menu.

If you run PythonWin, File/New gives you the option to create a new
Python script. To begin with, you can save into the Lib folder of your
Python installation (probably C:\Python25\Lib). I usually add my
initials at the front of the script name to differentiate my scripts
from the standard ones if I put stuff in Lib.

You should be able edit your PYTHONPATH variable in PythonWin - see
the Tools options (though, now I look, my installation actually has a
bug in this function), or alternatively, you can add a folder to your
PYTHONPATH environment variable in RegEdit (if you know what you're
doing).

I hope this helps.

J.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python on window

2007-03-23 Thread jwelby
That should have been:

"You should be able edit your PYTHONPATH variable (should you need
to)..."

Gabiel is right, it's not usually required.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a non-root daemon process

2007-03-23 Thread Ben Finney
"Leo Kislov" <[EMAIL PROTECTED]> writes:

> On Mar 22, 11:19 pm, Ben Finney <[EMAIL PROTECTED]> wrote:
> > The problem I'm having is that 'os.setsid()' fails with 'OSError:
> > [Errno 1] Operation not permitted' unless I run the program as the
> > root user. This isn't a program that I want necessarily running as
> > root.
>
> It works for me. I mean your program above produces no exceptions
> for me on Debian 3.1 python2.4

Hmm. I typed the example program in as a simplified version of what
I'm doing; but didn't actually *run* it. When I do run it, I get no
exception, as you say.

Now I'll have to find out what significant difference there is between
my failing code and this example, and report back in this thread.

Thanks for showing me this far :-)

-- 
 \"Some people, when confronted with a problem, think 'I know, |
  `\   I'll use regular expressions'. Now they have two problems."  -- |
_o__)Jamie Zawinski, in alt.religion.emacs |
Ben Finney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how can I invoke a Java code?

2007-03-23 Thread Jarek Zgoda
momobear napisał(a):

> A friend of my write a Java program, and I want use it in my python
> program as a module. I searched the topic in Google and find maybe the
> better way is use GCJ to compile it. Is there any other way for me?
> the simple and speediness choice the better. thanks.

If the speed is crucial, I suggest compiling the Java code with GCJ,
then write Python extension module for the Java library. This is how the
Lucene indexing library is ported to Python, see
http://pylucene.osafoundation.org/.

-- 
Jarek Zgoda

"We read Knuth so you don't have to."
-- 
http://mail.python.org/mailman/listinfo/python-list


$1 download the newest pda software

2007-03-23 Thread downloadpda
Want access to 15000+ all the new pda applications? just $1
register for one account  to download/buy applications in this site.
http://handpedia.vicp.cc/

this is one-time email, thank your reading.

-- 
http://mail.python.org/mailman/listinfo/python-list


Create new processes over telnet in XP

2007-03-23 Thread Godzilla
Hello,

How do you create/spawn new processes in XP over telnet using python?
I.e. I would like to create a new process and have it running in the
background... when I terminate the telnet connection, I would what the
spawned processes to keep running until I shut it off...

I got the os.popen method to spawn a new process running in the
backgroun, but not over telnet... tried os.popen[2, 3, 4] and also
subprocesses.popen without any luck...

Any help will be appreciated... thankyou.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help to learn Python

2007-03-23 Thread Benjamin Hell
Hi!

PythonBiter wrote:
> I'm very new in this Group as well Python language. I want to learn
> Python. So could you please advice me, and guide me how can i become
> master in Python !

If you are new to programming in general, too, the "Non-Programmer's
Tutorial for Python" is a good start:

http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python


Cheers,

Ben
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making GIF image twice the size - in memory

2007-03-23 Thread Michele Petrazzo
Miki wrote:
> Hello All,
> 

Heelo,

> I get an image from a web page (via urlopen), and like to make it 
> twice the size.

<-cut->

> However I don't get a valid GIF image.
> 

Your code work well here!
Why you said that the string are invalid?

--code: test_image_double.py

from urllib import urlopen
import Image
from ImageFile import Parser

def double(image_data):
 image_parser = Parser()
 image_parser.feed(image_data)
 im = image_parser.close()
 new_size = tuple(map(lambda x: 2 * x, im.size))
 new = im.resize(new_size)

 return new.tostring("gif", "P"), new, new_size

url = "http://www.google.com/intl/en_ALL/images/logo.gif";
image_data = urlopen(url).read()
image_data, img, new_size = double(image_data)
img_new = Image.fromstring("P", new_size, image_data, "gif")
img_new.save("./out1.gif")
img.save("./out2.gif")
print "PIL version:", Image.VERSION

-- test

michele:~/tmp$ python test_image_double.py && file out1.gif && file out2.gif
(552, 220) 49554
PIL version: 1.1.5
out1.gif: GIF image data, version 87a, 552 x 220
out2.gif: GIF image data, version 87a, 552 x 220
michele:~/tmp$

> Any ideas?
> 

Forgot to specify that the data aren't in raw format, but to decode it
with the "gif" encoder?

> Thanks,

Ciao,
Michele
-- 
http://mail.python.org/mailman/listinfo/python-list


"finally" for unit test

2007-03-23 Thread killkolor
hi!

I have a unittest framework that tests a single function that in turn
works with files (takes input and outputs in the same file, no return
values).
In the unittest class I assign a member with all the names of my
testfiles and a testdirectory. The tests call the function (which
opens and writes to the file) and then opens the file to see if
everything is in order. The problem now is that after each testrun I
have to copy "fresh" files into the testdirectory, since of course the
function already run on all the files and made the changes. So I
implemented a buffering in the unittest functions: buffer the file,
call the function, make the test, write the buffered file back. This
works fine for unittests that do not fail. If a unittest fails though
the function stops and the writing back is never done. Is there
something like a finally for unittest functions? Or could I use
another approach to buffer and write back my files (for each unittest
function)?
thanks!
gabriel

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idiom for running compiled python scripts?

2007-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2007 07:30:58 +, Mark wrote:

> On Fri, 23 Mar 2007 14:03:12 +1100, Steven D'Aprano wrote:
>> Since you've done these tests already, perhaps you can tell us what gain
>> you actually got?
> 
> About the same as you, ~20 msecs for my small script samples.

Well, I think that pretty much answers your question about whether it is
worth pre-compiling short shell scripts: you save about 20ms in execution
time, and lose 200ms in typing time. (Maybe a bit less if you are a
fast typist and don't use auto-completion.) You do the maths.


>> Of course you have to type the "c". You're not deleting the source files
>> away are you? *wink*
> 
> Sorry, the wink is lost on me?

It is because I didn't really think you were deleting the source files.
That would be incredibly stupid. But I mentioned it just in case some
not-so-bright spark decided to argue that you could use auto-completion
without needing to type that final "c" if you deleted the source file.

Presumably now somebody is going to suggest merely *moving* the source
files into another directory, thus spending a minute or two each time they
edit a script re-arranging files in order to save twenty or thirty
milliseconds when they execute the script. Hey, if your time is so
valuable that 20ms means that much to you, go for it.


> Of course I am not deleting the sources. In fact, I am also talking
> about python scripts being called from shell scripts. I guess I'm just
> surprised that the python installation does not provide a small stub
> invoker, e.g:
> 
> A small script called "python_compile_and_run" in "pseudo" code:

[snip pseudo-code]

> so I could just do a "python_compile_and_run myscript.py" and it would
> do what I want, i.e. run myscript.pyc if available and valid, generate
> and run it if necessary.

You shouldn't expect Python to come with every imaginable special-purpose
script already written for you! Besides, it's pretty simple to get that
functionality by hand when you need it, or automatically for that matter.

Here's one (untested) script that executes the pyc file in a subshell if
it exists and is new enough, and compiles it if it doesn't.


import os, sys, compiler
from stat import ST_MTIME as MT
if __name__ == "__main__":
scriptname = sys.argv[1]
compiledname = scriptname + "c"
if not os.path.exists(compiledname) or \
os.stat(compiledname)[MT] < os.stat(scriptname)[MT]:
# compiled file doesn't exist, or is too old
compiler.compileFile(scriptname)
assert os.path.exists(compiledname)
resultcode = os.system('python %s' % compiledname)
sys.exit(resultcode)

Now don't forget to test whether launching the subshell takes longer than
the 20ms you might save. All that effort, and wouldn't it be ironic if it
was actually *slower* than executing the script from scratch each time...


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2007 04:18:59 -0700, killkolor wrote:

> The problem now is that after each testrun I have to copy "fresh" files
> into the testdirectory, since of course the function already run on all
> the files and made the changes. So I implemented a buffering in the
> unittest functions: buffer the file, call the function, make the test,
> write the buffered file back. This works fine for unittests that do not
> fail. If a unittest fails though the function stops and the writing back
> is never done. Is there something like a finally for unittest functions?
> Or could I use another approach to buffer and write back my files (for
> each unittest function)?

A simple approach would be to copy the test files *before* running the
tests, instead of after. That way it doesn't matter if the tests fail or
not: the next run will simply replace the test files with known good
copies, regardless.



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Been a while...

2007-03-23 Thread Paul Boddie
On 22 Mar, 16:34, John Salerno <[EMAIL PROTECTED]> wrote:
> Hi guys. It's been a while since I've used Python, so I got a little
> rusty, but I really want to start using it again, just out of habit and
> for fun. Can anyone suggest a book or a website with little projects I
> could work on to keep me busy?

The Python Wiki's Beginner's Guide is one place to start:

http://wiki.python.org/moin/BeginnersGuide

> (I do have Beginning Python with the 10 projects in the back, but those
> might be a little too involved for me right now.)

There are many ideas for projects on the Wiki, too:

http://wiki.python.org/moin/CodingProjectIdeas

I think a lot of them might be quite difficult for beginners, however.

Paul

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create new processes over telnet in XP

2007-03-23 Thread rishi pathak

You could use pexpect module.
Open a telnet session
Then run the script in nohup mode
It's assumed that the binary is available over there

On 23 Mar 2007 03:47:14 -0700, Godzilla <[EMAIL PROTECTED]> wrote:


Hello,

How do you create/spawn new processes in XP over telnet using python?
I.e. I would like to create a new process and have it running in the
background... when I terminate the telnet connection, I would what the
spawned processes to keep running until I shut it off...

I got the os.popen method to spawn a new process running in the
backgroun, but not over telnet... tried os.popen[2, 3, 4] and also
subprocesses.popen without any luck...

Any help will be appreciated... thankyou.

--
http://mail.python.org/mailman/listinfo/python-list





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: "finally" for unit test

2007-03-23 Thread Peter Otten
killkolor wrote:

> I have a unittest framework that tests a single function that in turn
> works with files (takes input and outputs in the same file, no return
> values).
> In the unittest class I assign a member with all the names of my
> testfiles and a testdirectory. The tests call the function (which
> opens and writes to the file) and then opens the file to see if
> everything is in order. The problem now is that after each testrun I
> have to copy "fresh" files into the testdirectory, since of course the
> function already run on all the files and made the changes. So I
> implemented a buffering in the unittest functions: buffer the file,
> call the function, make the test, write the buffered file back. This
> works fine for unittests that do not fail. If a unittest fails though
> the function stops and the writing back is never done. Is there
> something like a finally for unittest functions? 

TestCase.tearDown()

http://docs.python.org/lib/testcase-objects.html#l2h-5002

> Or could I use 
> another approach to buffer and write back my files (for each unittest
> function)?

Rather than restoring the file I would just delete it and use

TestCase.setUp() to make a fresh copy.

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help controlling CDROM from python

2007-03-23 Thread R. Bernstein
If you want an OS neutral way one may be able to use pycdio from the
Cheese shop.

It requires libcdio to be installed and that sometimes the case if you
have a free media player (like vlc or xine, or mplayer) installed.

I don't really use it all that often so I can't vouch for how good it
is. (Although there *are* regression tests). 

Ognjen Bezanov <[EMAIL PROTECTED]> writes:

> Hello,
> 
> I am trying to control a CD-ROM drive using python. The code I use is
> shown below.
> 
> > import CDROM
> > from fcntl import ioctl
> > import os
> > 
> > 
> > class Device:
> > 
> > CDdevice=""
> > CDfd = None
> > 
> > def __init__(self,name):
> > self.CDdevice = name#we get a device name when module loaded
> > 
> > if self.CDdevice == "":
> > print "No device specified"
> > sys.exit(-1)
> > self.openCD()   
> > 
> > def openCD(self):
> > 
> > try:
> > self.CDfd = open(self.CDdevice, 'r') #open the device 
> > and return filedescriptor 
> > 
> > except(OSError,IOError): #if there is an OS or IO Error 
> > (usually indicates nodisk)
> > print "Device Error, Halting (usually means drive 
> > or disk not found)"  
> > sys.exit(-1)
> 
> > def unlockCD(self):
> > return self.sendCDcommand(CDROM.CDROM_LOCKDOOR,0)
> 
> > def ejectCD(self):
> > self.unlockCD() #we need to unlock the CD tray before we try to 
> > eject, otherwise we get an IO Error (#5)
> > return self.sendCDcommand(CDROM.CDROMEJECT)
> > 
> 
> 
> > def sendCDcommand(self,command,argument=''):
> > return ioctl(self.CDfd,command,argument)
> > 
> 
> 
> 
> The code that calls the class is a follows:
> 
> > import CD_Bindings
> > 
> > CD = CD_Bindings.Device("/dev/cdrom")
> > 
> > print CD.ejectCD()
> 
> This works great, but only when there is a disk inside, otherwise we get
> an error.
> 
> My issue is that I need to be able to eject the CDROM tray even if there
> is no disk inside.
> 
> This is possible because other programs (like the linux "eject" command)
> can do it. Its just a question of how it is done in python. So I'm
> posting here in the hope someone can tell me.
> 
> Thanks,
> 
> Ognjen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread Duncan Booth
"killkolor" <[EMAIL PROTECTED]> wrote:

> I have a unittest framework that tests a single function that in turn
> works with files (takes input and outputs in the same file, no return
> values).

I would want to split that function into two:

a) one which does the processing, but not working with a file,
b) and one which handles reading and calls the processing function and then 
writes the file. The function it calls would be passed in as an optional 
parameter and defaults to function (a)

Then you need two sets of tests:

 one to test the action of reading data from a file and then rewriting the 
output in-place, but you just pass in a mock function for the processing 
which can assert that it saw the expected inputs.

 and as many tests as you want for the processing, but no annoying files to 
get in the way.

If you really cannot have the processing without reading from a file, then 
let it take two files, input and output as parameters, and have the (b) 
function choose between calling it with separate input/output files or 
creating a temporary file which is renamed to replace the original on 
completion. Then at least you can read directly from the test inputs 
without ever needing to write them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idiom for running compiled python scripts?

2007-03-23 Thread mark
On Fri, 23 Mar 2007 22:24:07 +1100, Steven D'Aprano wrote:
> if not os.path.exists(compiledname) or \ os.stat(compiledname)[MT] <
> os.stat(scriptname)[MT]:
> # compiled file doesn't exist, or is too old

Surely the validity check done by Python is more sophisticated than
this? Doesn't the binary file have to be compiled under the same python
version etc?

> Now don't forget to test whether launching the subshell takes longer
> than the 20ms you might save. All that effort, and wouldn't it be ironic
> if it was actually *slower* than executing the script from scratch each
> time...

But Python proper is executing all the above anyhow isn't it? So the 20
msecs advantage I measured already includes this logic.

Anyhow, I give up. Compilation, it seems, only applies to python
modules. Compilation is not appropriate for Python scripts. Should be
in the FAQ.
-- 
http://mail.python.org/mailman/listinfo/python-list


Cleanly exiting multi thread application on SIGINT

2007-03-23 Thread jrpfinch
Is the following the most elegant way to exit a multi-threaded
application on a Ctrl-C?  I am a complete beginner and would have
thought there was some way of doing it without having to use while 1:
pass, but have yet to find a way.

N.B. exit() is a method for cleanly exiting the thread using a queue.

Many thanks

Jon

def main:
wt = workerThread()
wt.setDaemon(True)
wt.start()
ct = counterThread()
ct.setDaemon(True)
ct.start()
try:
while 1:
pass
except KeyboardInterrupt:
wt.exit()
ct.exit()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: On Java's Interface (the meaning of interface in computer programing)

2007-03-23 Thread Lew
Sherm Pendley wrote:
> Lew <[EMAIL PROTECTED]> writes:
> 
>> Jim Burton wrote:
>>> Or you could stop feeding the trolls.
>> Does not apply. The OP was not being trollish
> 
> You obviously don't know Xah. He's been doing this for years, cross-
> posting to various language groups trying to start an argument between
> them. He even brags about being a troll on his web site.

OK - that last is telling. I believe in the possibility of redemption: if a 
troll posts non-trollishly then I am willing to give them the benefit of the 
doubt.

But if Xah were being trollish, why didn't they jump on my response and call 
me names?

I still think that analysis of the original post is a useful exercise to learn 
Java. It's one thing to know what's right - it's another to know what's wrong 
and exactly why. The more subtle Xah or other minions of Satan get in their 
presentations, the more interesting the forensic exercise to dig out the truth.

Perhaps I am just trying to make a silk purse out of a sow's ear.

-- Lew
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to receive a FILE* from Python under MinGW?

2007-03-23 Thread John Pye
On Mar 23, 7:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
>
> And replace all places where a Python file goes into a C extension, with
> exportable_file(f)

What about calling mscvrt_get_osfhandle from inside the SWIG wrapper?
I tried this but it seemed that the function was not exported to the
DLL.

Cheers
JP

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread killkolor
I went with the TestCase.setUp() function.
Thanks a lot!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help to learn Python

2007-03-23 Thread Graeme Glass
Online Docs, and Core Python Programming fits the bill! (http://
starship.python.net/crew/wesc/cpp/)

-- 
http://mail.python.org/mailman/listinfo/python-list


Catching an unknown error

2007-03-23 Thread Harlin Seritt
Using the code below:

---BEGIN CODE---

value = raw_input("Type a divisor: ")
try:
   value = int(value)
   print "42 / %d = %d" % (value, 42/value)
except ValueError:
print "I can't convert the value to an integer"
except ZeroDivisionError:
print "Your value should not be zero"
except:
print "Something unexpected happened"

---END CODE---

In the last 'except' block, how can I print out the particular error
name even though one is not specifically named?

Thanks,

Harlin

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help to learn Python

2007-03-23 Thread kyosohma
On Mar 23, 12:03 am, "PythonBiter" <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm very new in this Group as well Python language. I want to learn
> Python. So could you please advice me, and guide me how can i become
> master in Python !
>
> Thanks,
> Partha

If you need books for a beginner in Python, go with "Python
Programming for the Absolute Beginner" by Dawson, or "Python
Programming: An Introduction to Computer Science" by Zelle.

Core Python Programming is mostly theory and very little code. It's
good for reference and digging deeper into the language, if you don't
mind some screwy grammatical errors here and there. Programming Python
3rd Ed (by Lutz) has lots of code to dig into, but I would say it is
for intermediate to advanced users. It also contains many practical
useful scripts in it.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread kyosohma
On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
> Using the code below:
>
> ---BEGIN CODE---
>
> value = raw_input("Type a divisor: ")
> try:
>value = int(value)
>print "42 / %d = %d" % (value, 42/value)
> except ValueError:
> print "I can't convert the value to an integer"
> except ZeroDivisionError:
> print "Your value should not be zero"
> except:
> print "Something unexpected happened"
>
> ---END CODE---
>
> In the last 'except' block, how can I print out the particular error
> name even though one is not specifically named?
>
> Thanks,
>
> Harlin

Make the last 'except' block like this:

Except Exception, e:
   print e


Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread Fredrik Lundh
Harlin Seritt wrote:

> In the last 'except' block, how can I print out the particular error
> name even though one is not specifically named?

the sys.exc_info() function returns information about the current exception.
see:

http://effbot.org/pyref/sys.exc_info

 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread kyosohma
On Mar 23, 8:29 am, [EMAIL PROTECTED] wrote:
> On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Using the code below:
>
> > ---BEGIN CODE---
>
> > value = raw_input("Type a divisor: ")
> > try:
> >value = int(value)
> >print "42 / %d = %d" % (value, 42/value)
> > except ValueError:
> > print "I can't convert the value to an integer"
> > except ZeroDivisionError:
> > print "Your value should not be zero"
> > except:
> > print "Something unexpected happened"
>
> > ---END CODE---
>
> > In the last 'except' block, how can I print out the particular error
> > name even though one is not specifically named?
>
> > Thanks,
>
> > Harlin
>
> Make the last 'except' block like this:
>
> Except Exception, e:
>print e
>
> Mike

just don't capitalize the word "except" ... my bad

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> Make the last 'except' block like this:
>
> Except Exception, e:
>   print e

while that's good enough for the given example, it's not good enough for
the general case (in contemporary Python, exceptions don't have to inherit
from the Exception class).

 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cleanly exiting multi thread application on SIGINT

2007-03-23 Thread Fredrik Lundh
"jrpfinch" wrote:

> Is the following the most elegant way to exit a multi-threaded
> application on a Ctrl-C?  I am a complete beginner and would have
> thought there was some way of doing it without having to use while 1:
> pass, but have yet to find a way.

> def main:
>wt = workerThread()
>wt.setDaemon(True)
>wt.start()
>ct = counterThread()
>ct.setDaemon(True)
>ct.start()
>try:
>while 1:
>pass

you could at least insert a time.sleep(1), to avoid busy-looping.

 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread kyosohma
On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
> Using the code below:
>
> ---BEGIN CODE---
>
> value = raw_input("Type a divisor: ")
> try:
>value = int(value)
>print "42 / %d = %d" % (value, 42/value)
> except ValueError:
> print "I can't convert the value to an integer"
> except ZeroDivisionError:
> print "Your value should not be zero"
> except:
> print "Something unexpected happened"
>
> ---END CODE---
>
> In the last 'except' block, how can I print out the particular error
> name even though one is not specifically named?
>
> Thanks,
>
> Harlin

Thanks for pointing that out. I was following logic I was taught in
Hetland's book, which supposedly was up-to-date for Python 2.4.
Typical textbook error.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need help to learn Python

2007-03-23 Thread Tina I
PythonBiter wrote:
> Hi everyone,
> 
> I'm very new in this Group as well Python language. I want to learn
> Python. So could you please advice me, and guide me how can i become
> master in Python !
> 
> 
> Thanks,
> Partha
> 
Lots of great resources for beginners: 
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idiom for running compiled python scripts?

2007-03-23 Thread Steven D'Aprano
On Fri, 23 Mar 2007 12:22:44 +, mark wrote:

> On Fri, 23 Mar 2007 22:24:07 +1100, Steven D'Aprano wrote:
>> if not os.path.exists(compiledname) or \ os.stat(compiledname)[MT] <
>> os.stat(scriptname)[MT]:
>> # compiled file doesn't exist, or is too old
> 
> Surely the validity check done by Python is more sophisticated than
> this? Doesn't the binary file have to be compiled under the same python
> version etc?

Of course. What, do you want me to do all your work? :-)



>> Now don't forget to test whether launching the subshell takes longer
>> than the 20ms you might save. All that effort, and wouldn't it be ironic
>> if it was actually *slower* than executing the script from scratch each
>> time...
> 
> But Python proper is executing all the above anyhow isn't it? So the 20
> msecs advantage I measured already includes this logic.

I don't know how you measured the 20ms.

When you call a script direct from the shell, you've already got a shell
running. When you call a script from within Python via os.system, it has
to launch a sub-shell. That takes time.


> Anyhow, I give up. Compilation, it seems, only applies to python
> modules. Compilation is not appropriate for Python scripts. Should be
> in the FAQ.

No, that's not true. Python scripts certainly take advantage of compiled
modules.

The real lesson of this is that optimization isn't necessarily
straightforward. What we imagine "should be" faster might not be in
practice -- especially when dealing with micro-optimizations that only
save a few tens of milliseconds.

Frankly, it simply isn't worth trying to save 20ms in a script that takes
less than a second to run. If you scratch your nose before hitting enter,
you've wasted a hundred times what you've just spent hours trying to save.

Or, to put it another way:

The Rules of Optimization are simple. 
Rule 1: Don't do it. 
Rule 2 (for experts only): Don't do it yet.
-- Michael A. Jackson (no, not that Michael Jackson), "Principles of
Program Design", 1975.



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread Harlin Seritt
On Mar 23, 9:42 am, [EMAIL PROTECTED] wrote:
> On Mar 23, 8:16 am, "Harlin Seritt" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Using the code below:
>
> > ---BEGIN CODE---
>
> > value = raw_input("Type a divisor: ")
> > try:
> >value = int(value)
> >print "42 / %d = %d" % (value, 42/value)
> > except ValueError:
> > print "I can't convert the value to an integer"
> > except ZeroDivisionError:
> > print "Your value should not be zero"
> > except:
> > print "Something unexpected happened"
>
> > ---END CODE---
>
> > In the last 'except' block, how can I print out the particular error
> > name even though one is not specifically named?
>
> > Thanks,
>
> > Harlin
>
> Thanks for pointing that out. I was following logic I was taught in
> Hetland's book, which supposedly was up-to-date for Python 2.4.
> Typical textbook error.
>
> Mike

Thanks guys... that gets 'er done.

Harlin Seritt

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create new processes over telnet in XP

2007-03-23 Thread Rob Wolfe

Godzilla wrote:
> Hello,
>
> How do you create/spawn new processes in XP over telnet using python?
> I.e. I would like to create a new process and have it running in the
> background... when I terminate the telnet connection, I would what the
> spawned processes to keep running until I shut it off...
>
> I got the os.popen method to spawn a new process running in the
> backgroun, but not over telnet... tried os.popen[2, 3, 4] and also
> subprocesses.popen without any luck...

I don't know what kind of OS there is on that remote host you telnet
to.
The idea boils down to appropriate using of methods
`read_until` and `write` from class `telnetlib.Telnet`.

For more complicated stuff you can consider using pyexpect.

Here is a small example of connecting to HP-UX.
You can adjust that to your needs.


import telnetlib, time

def login(tn, login, passwd, prompt):
tn.read_until("login: ")
tn.write(login + "\n")
if passwd:
tn.read_until("Password: ")
tn.write(passwd + "\n")
tn.read_until(prompt)
time.sleep(2)
print "logged in"

def run_proc(tn, progname):
tn.write("nohup %s &\n" % progname)
tn.write("exit\n")
print "program <%s> running" % progname

def kill_proc(tn, login, prompt, progname):
tn.write("ps -u %s\n" % login)
buf = tn.read_until(prompt)
pid = get_pid(buf, progname)
if not pid:
print "program <%s> not killed" % progname
tn.write("exit\n")
return
tn.write("kill -TERM %s\n" % pid)
tn.write("exit\n")
print "program <%s> killed" % progname

def get_pid(buf, progname):
pid, comm = None, None
for line in buf.split("\n"):
try:
pid, _, _, comm = line.split()
except ValueError:
continue
if comm == progname:
return pid

tn = telnetlib.Telnet(HOST, PORT)
#tn.set_debuglevel(1)
login(tn, "login", "passwd", "/home/user")
run_proc(tn, "python ~/test.py")
#kill_proc(tn, "login", "/home/user", "python")


--
HTH,
Rob

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread skip
gabriel> Is there something like a finally for unittest functions?

TestCase instances have setUp() and tearDown() methods:

http://docs.python.org/dev/lib/testcase-objects.html

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching an unknown error

2007-03-23 Thread skip

Harlin> value = raw_input("Type a divisor: ")
Harlin> try:
Harlin>value = int(value)
Harlin>print "42 / %d = %d" % (value, 42/value)
Harlin> except ValueError:
Harlin> print "I can't convert the value to an integer"
Harlin> except ZeroDivisionError:
Harlin> print "Your value should not be zero"
Harlin> except:
Harlin> print "Something unexpected happened"

Harlin> In the last 'except' block, how can I print out the particular
Harlin> error name even though one is not specifically named?

>>> try:
...   1/0
... except Exception, err:
...   print repr(err)
...


Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cleanly exiting multi thread application on SIGINT

2007-03-23 Thread skip

Jon> Is the following the most elegant way to exit a multi-threaded
Jon> application on a Ctrl-C?  I am a complete beginner and would have
Jon> thought there was some way of doing it without having to use while
Jon> 1: pass, but have yet to find a way.

I thought there was some sort of wait() method in the threading module, but
I was mistaken.  Maybe:

while threading.activeCount():
time.sleep(0.01)

?

Skip
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wikipedia and a little piece of Python History

2007-03-23 Thread Jorgen Grahn
On 21 Mar 2007 12:18:50 -0700, Paddy <[EMAIL PROTECTED]> wrote:
> I just had a link to Tim peters first post on doctest:
> http://groups.google.com/group/comp.lang.python/msg/1c57cfb7b3772763
> removed from http://en.wikipedia.org/wiki/Doctest as it doesn't fit
> their guidelines for external links.
> I wonder, could maybe the official website be persuaded to host a copy
> so that it could be linked to?

Wikipedia should have some guideline for referencing Usenet postings,
somewhere ...

Anyway, it's a good thing to provide at least the Message-ID of the
posting. As an example, your your posting here was uniquely identified
by the Message-ID

  <[EMAIL PROTECTED]>

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Exception passing

2007-03-23 Thread Thomas Dybdahl Ahle
Hi, I have a function, which looks like the following:

connecting = False
def func ():
global connecting
connecting = True
try:
   # Do lot of network stuff
except Exception, e:
connecting = False
raise e

This works quite good, but it is a hell to debug. Instead of getting a 
log message to the line which originally raised the exception.

Is there anyway to reraise an exception, but preserve the log?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception passing

2007-03-23 Thread kyosohma
On Mar 23, 9:29 am, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:
> Hi, I have a function, which looks like the following:
>
> connecting = False
> def func ():
> global connecting
> connecting = True
> try:
># Do lot of network stuff
> except Exception, e:
> connecting = False
> raise e
>
> This works quite good, but it is a hell to debug. Instead of getting a
> log message to the line which originally raised the exception.
>
> Is there anyway to reraise an exception, but preserve the log?

You could import traceback and use its functionality.

Lundh mentioned using sys.exc_info about an hour ago to another user.
See http://effbot.org/pyref/sys.exc_info.htm

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception passing

2007-03-23 Thread Alex Martelli
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:

> Hi, I have a function, which looks like the following:
> 
> connecting = False
> def func ():
> global connecting
> connecting = True
> try:
># Do lot of network stuff
> except Exception, e:
> connecting = False
> raise e
> 
> This works quite good, but it is a hell to debug. Instead of getting a
> log message to the line which originally raised the exception.
> 
> Is there anyway to reraise an exception, but preserve the log?

Just use
  raise
without any argument.

E.g.:

>>> def raiser():  
...   print 1/0
... 
>>> def reraise1():
...   print 'before'
...   try: raiser()
...   except Exception, e:
... print 'after'
... raise e
... 
>>> def reraise2():
...   print 'before'
...   try: raiser()
...   except Exception, e:
... print 'after'
... raise  
... 
>>> reraise1()
before
after
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 6, in reraise1
ZeroDivisionError: integer division or modulo by zero
>>> reraise2()
before
after
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in reraise2
  File "", line 2, in raiser
ZeroDivisionError: integer division or modulo by zero
>>> 

As you see, the traceback is "maintained" when you just "raise", though
it's altered when you "raise e".


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create new processes over telnet in XP

2007-03-23 Thread Jorgen Grahn
On 23 Mar 2007 03:47:14 -0700, Godzilla <[EMAIL PROTECTED]> wrote:
> Hello,
>
> How do you create/spawn new processes in XP over telnet using python?
> I.e. I would like to create a new process and have it running in the
> background...

Ssh -- or even rsh -- are better choices than telnet for these things.
For some reason, they are not standard in Windows, though.

  ssh somewhere some command with arguments
  rsh somewhere some command with arguments

compared to

  telnet somewhere

and then performing expect-like things (basically simulating
someone typing "some command with arguments" in the telnet
session).

> when I terminate the telnet connection, I would what the
> spawned processes to keep running until I shut it off...

That's a function of the remote OS; what happens when its terminal
goes away is not under the control of the client side.

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idiom for running compiled python scripts?

2007-03-23 Thread Alex Martelli
Mark <[EMAIL PROTECTED]> wrote:
   ...
> so I could just do a "python_compile_and_run myscript.py" and it would
> do what I want, i.e. run myscript.pyc if available and valid, generate
> and run it if necessary.

You can use

python -c 'import myscript; myscript.main()'

and variations thereon.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread Jorgen Grahn
On 23 Mar 2007 12:19:15 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
> "killkolor" <[EMAIL PROTECTED]> wrote:
>
>> I have a unittest framework that tests a single function that in turn
>> works with files (takes input and outputs in the same file, no return
>> values).
>
> I would want to split that function into two:
>
> a) one which does the processing, but not working with a file,

Better to make it work with "a file", in the sense that it works with
file-like objects so you can feed and leech it using StringIO.

> b) and one which handles reading and calls the processing function and then 
> writes the file. The function it calls would be passed in as an optional 
> parameter and defaults to function (a)

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exception passing

2007-03-23 Thread Thomas Dybdahl Ahle
Den Fri, 23 Mar 2007 07:38:47 -0700 skrev Alex Martelli:

> Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote:

>> This works quite good, but it is a hell to debug. Instead of getting a
>> log message to the line which originally raised the exception.

> As you see, the traceback is "maintained" when you just "raise", though
> it's altered when you "raise e".

Thanks a lot :D
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mocking OpenOffice in python?

2007-03-23 Thread Gerrit Muller
Méta-MCI schreef:
> Hi!
> 
> 
> Under windows, I drive OOo, from Python, via COM/OLE-automation.
> 
> It's run OK, but some bugs, in the OOo-COM-Python, had stop my 
> devloppements...
> 
> However, this way is usable (only on Win, ok?)
> 
Do you have some (small) example program of using OOo from Python via 
COM/OLE?

Can you give any indication of the kind of bugs that you hit?

kind regards, Gerrit Muller

Gaudi Systems Architecting 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)

2007-03-23 Thread Jorgen Grahn
On Thu, 22 Mar 2007 14:20:42 -0400, Steve Holden <[EMAIL PROTECTED]> wrote:
...
> I'm in danger of getting short-tempered on c.l.py for the first time in 
> a long time. If you think that five arguments is an excessive number for 
> a function then you live in a world of toy programs.

Or at least in a world where people have good taste and time to Do It
Right(tm).

I personally believe many five-argument methods would be better off
refactored. I killed one today which had fourteen (most of which were
unused).  But I don't pretend that it's always worth the effort of
doing that, in the real world.

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread Duncan Booth
Jorgen Grahn <[EMAIL PROTECTED]> wrote:

> On 23 Mar 2007 12:19:15 GMT, Duncan Booth
> <[EMAIL PROTECTED]> wrote: 
>> "killkolor" <[EMAIL PROTECTED]> wrote:
>>
>>> I have a unittest framework that tests a single function that in
>>> turn works with files (takes input and outputs in the same file, no
>>> return values).
>>
>> I would want to split that function into two:
>>
>> a) one which does the processing, but not working with a file,
> 
> Better to make it work with "a file", in the sense that it works with
> file-like objects so you can feed and leech it using StringIO.

I'm assuming, perhaps wrongly, that something which takes input from a file 
and produces output into the same file is doing something beyond the simple 
interface supported by StringIO. So I was guessing either that something 
like FileInput is involved, or seeking and modifying in-place.

Anyway, the principle is the same: you make sure no function does more than 
one job, and you make sure that all functions are testable independently.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to list current line in pdb?

2007-03-23 Thread Chris Lasher
Hi all,

Using the pdb shell, after repeatedly entering 'l' (lowercase 'L'),
how do I jump back to listing the current line again if I don't
remember exactly what line my current line is? Do I just have to list
an early line in the code and repeatedly list from there until I see
the '->' indicating the current line?

Thanks,
Chris

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fine grain logging cotrol

2007-03-23 Thread Eric S. Johansson
Peter Otten wrote:
> Eric S. Johansson wrote:
> 
> [in private mail -- please don't, Eric]

sorry.  my preference is for private mail.  it's my way of trying to be 
kind to others by reducing list clutter.

> I don't understand. The logging package detects the function name without
> user intervention. 

not in 2.4 afaik.  according to the docs for debug/info it the only 
kwargs which is inspected is exc_info.

> Perhaps it's time to step back and explain what you want to achieve rather
> than how you proceed.

print a log message if a predicate yields true.

should be able to have different predicates.

the desired predicate is a match on class, method, and level number. 
class and method should be found automatically by the logging predicate 
code.

apologies again for violating your email protocol and thanks for the help.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to list current line in pdb?

2007-03-23 Thread Duncan Booth
"Chris Lasher" <[EMAIL PROTECTED]> wrote:

> Using the pdb shell, after repeatedly entering 'l' (lowercase 'L'),
> how do I jump back to listing the current line again if I don't
> remember exactly what line my current line is? Do I just have to list
> an early line in the code and repeatedly list from there until I see
> the '->' indicating the current line?

Try:

(Pdb) alias ll u;;d;;l


and thereafter the 'll' command will list the current line (unless you are 
in the uppermost stack frame in which case it goes down one stackframe 
instead).

Save the alias in your .pdbrc file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GCC 4.1.2 installer for Python distutils compilation

2007-03-23 Thread David Rushby
On Mar 18, 6:22 pm, Giovanni Bajo <[EMAIL PROTECTED]> wrote:
> On 18/03/2007 13.24, DavidRushbywrote:
>
> > Even though I have access to MSVC 7.1, so I don't really need MinGW
> > myself, [...]
>
> But remember that GCC 4.1.2 is almost 4 years newer than MSVC 7.1, and
> I found it to produce more optimized code (especially for C++). Since it's
> a free alternative, it might be worth to give it a go :)

I just wrote a high-performance Windows-1251 codec in C (an optimized
alternative to Python's including 'cp1251' codec).

On Windows 2000 / Prescott PIV, GCC 4.1.2 does indeed produce code
that is 30% faster than MSVC (this is with aggressive optimization
switch tinkering on both compilers).  This is for fairly simple, non-
floating-point C code.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wikipedia and a little piece of Python History

2007-03-23 Thread Paul Rubin
Jorgen Grahn <[EMAIL PROTECTED]> writes:
> Wikipedia should have some guideline for referencing Usenet postings,
> somewhere ...

It has one (WP:RS).  The guideline is don't do it.  The problem is
that these guidelines arise out of disputes, i.e. maybe someone tried
to use a Usenet post to prove something about a politician, and the
result (reasonably) was a guideline that said Usenet posts weren't
reliable sources of info.  In the cases where it's something ok, the
editors use common sense and leave it alone.  Until that bot got loose
and started removing all Usenet links whether they were ok or not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Been a while...

2007-03-23 Thread Erik Johnson

"James Stroud" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Hawk this list and try to pick off easy answers before anyone else.
> That's what I do. The pressure is to be right, because if you're not,
> you hear about it in a hurry.

That is actually an excellent suggestion.  Even if you can't answer a
question, finding interesting and comprehanesible questions and then
studying the various follow up posts is an excellent way to sharpen your
Python skills, and broaden your knowledge about not only Python syntax and
common pitfalls but about what modules are typically applied to various
kinds of problems.

-ej


-- 
http://mail.python.org/mailman/listinfo/python-list


Multi-line strings with formatting

2007-03-23 Thread [EMAIL PROTECTED]
When constructing a particularly long and complicated command to be
sent to the shell, I usually do something like this, to make the
command as easy as possible to follow:

commands.getoutput(
'mycommand -S %d -T %d ' % (s_switch, t_switch)   +
'-f1 %s -f2 %s ' % (filename1, filename2) +
'> %s'   % (log_filename)
)

Can anyone suggest a better way to construct the command, especially
without the "+" sign at the end of each line (except the last) ? If I
take out the "+", then I need to move all the variables to the end, as
so:

commands.getoutput(
'mycommand -S %d -T %d '
'-f1 %s -f2 %s '
'> %s'
% (s_switch, t_switch, filename1, filename2, log_filename)
)

or:

commands.getoutput(
'''mycommand -S %d -T %d \
-f1 %s -f2 %s \
> %s'''
% (s_switch, t_switch, filename1, filename2, log_filename)
)

but having the variables line-by-line as in the first example is so
much easier to edit, is it not?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-line strings with formatting

2007-03-23 Thread Carsten Haese
On Fri, 2007-03-23 at 09:54 -0700, [EMAIL PROTECTED] wrote:
> When constructing a particularly long and complicated command to be
> sent to the shell, I usually do something like this, to make the
> command as easy as possible to follow:
> 
> commands.getoutput(
> 'mycommand -S %d -T %d ' % (s_switch, t_switch)   +
> '-f1 %s -f2 %s ' % (filename1, filename2) +
> '> %s'   % (log_filename)
> )
> 
> Can anyone suggest a better way to construct the command, especially
> without the "+" sign at the end of each line (except the last) ? If I
> take out the "+", then I need to move all the variables to the end, as
> so:
> 
> commands.getoutput(
> 'mycommand -S %d -T %d '
> '-f1 %s -f2 %s '
> '> %s'
> % (s_switch, t_switch, filename1, filename2, log_filename)
> )
> 
> or:
> 
> commands.getoutput(
> '''mycommand -S %d -T %d \
> -f1 %s -f2 %s \
> > %s'''
> % (s_switch, t_switch, filename1, filename2, log_filename)
> )

You get the best of both worlds, i.e. one big multiline string with
in-line parameters, by using a mapping:

commands.getoutput(
   '''mycommand -S %(s_switch)d -T %(t_switch)d \
-f1 %(filename1)s -f2 %(filename2)s \
> %(log_filename)s'''
% locals() )

Of course I'm assuming that s_switch etc. are local variables. If
they're not, well, they ought to be.

-Carsten


-- 
http://mail.python.org/mailman/listinfo/python-list


detect suprocess interaction

2007-03-23 Thread Robin Becker
I'm using subprocess to carry out svn commands (probably should use the svn api 
package, but that's a dependency too far). Anyhow my code looks like

from subprocess import Popen, PIPE
p = Popen((svn,'ls',u),stdout=PIPE,stderr=PIPE)
i = p.wait()

and this sort of thing works well under most circumstances. However, when this 
code is executed for the very first time by a particular user it hangs waiting 
on user input.

This code is being used purely for testing correctness of a particular svn url 
so in the normal case we want to throw away both stdout and stderr. In the 
exceptional case is it possible to detect that input is required and only in 
that case issue the current contents of stdout (presumably a request for a 
password)?

Clearly I need to supply some kind of input filelike object, but is this sort 
of 
thing possible.
-- 
Robin Becker

-- 
http://mail.python.org/mailman/listinfo/python-list


Compiler-AST-Walk-Visitor: Any Examples or Documentation?

2007-03-23 Thread Efrat Regev
 Hello,

 I'm trying to write something that will translate Python code to 
pseudo-code (for teaching purposes). Googling around indicated that the 
compiler module is pertinent, especially creating a visitor to walk the 
generated AST:
http://docs.python.org/lib/module-compiler.html

 I can build the AST, but I can't figure out how to write the 
visitor. The package documentation didn't help me out that much, and I 
couldn't find any examples. In fact, google only came up with this 
unanswered related question:
http://mail.python.org/pipermail/python-list/2006-July/392716.html

 Any help is appreciated.

  Thanks and Bye,

   Efrat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fine grain logging cotrol

2007-03-23 Thread Peter Otten
Eric S. Johansson wrote:

> Peter Otten wrote:
>> Eric S. Johansson wrote:
>> 
>> [in private mail -- please don't, Eric]
> 
> sorry.  my preference is for private mail.  it's my way of trying to be
> kind to others by reducing list clutter.

It is not list clutter in my book; it gives others the chance to correct,
add to, or even profit from our conversation.

>> I don't understand. The logging package detects the function name without
>> user intervention.
 
> not in 2.4 afaik.  

Hmm, I must have overread that constraint in your previous posts...

Here is yet another revision of my example then:

import logging
import sys

class LoggedType(type):
def __new__(mcl, name, bases, classdict):
def get_logger(self):
return logging.getLogger("%s.%s" % (name,
sys._getframe(1).f_code.co_name))
classdict["_%s__logger" % name] = property(get_logger)
return type.__new__(mcl, name, bases, classdict)

class Logged:
__metaclass__ = LoggedType

class Felis(Logged):
def alpha(self):
self.__logger.info("Felis.alpha")
def gamma(self):
self.__logger.info("Felis.gamma")

class Catus(Felis):
def alpha(self):
self.__logger.info("Catus.alpha")
def beta(self):
self.__logger.info("Catus.beta")

if __name__ == "__main__":
logging.basicConfig(
format="EXPECTED %(message)s GOT %(name)s", level=logging.INFO)
f = Felis()
f.alpha()
f.gamma()
c = Catus()
c.alpha()
c.beta()
c.gamma()

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


exit to interpreter?

2007-03-23 Thread belinda thom
Hi,

I'm writing a function that polls the user for keyboard input,  
looping until it has determined that the user has entered a valid  
string of characters, in which case it returns that string so it can  
be processed up the call stack. My problem is this. I'd also like it  
to handle a special string (e.g. 'quit'), in which case control  
should return to the Python command line as opposed to returning the  
string up the call stack.

sys.exit seemed like a good choice, but it exits the python interpreter.

I could use an exception for this purpose, but was wondering if  
there's a better way?

--b
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to list current line in pdb?

2007-03-23 Thread Chris Lasher
On Mar 23, 11:56 am, Duncan Booth <[EMAIL PROTECTED]>
wrote:
> "Chris Lasher" <[EMAIL PROTECTED]> wrote:
> > Using the pdb shell, after repeatedly entering 'l' (lowercase 'L'),
> > how do I jump back to listing the current line again if I don't
> > remember exactly what line my current line is? Do I just have to list
> > an early line in the code and repeatedly list from there until I see
> > the '->' indicating the current line?
>
> Try:
>
> (Pdb) alias ll u;;d;;l
>
> and thereafter the 'll' command will list the current line (unless you are
> in the uppermost stack frame in which case it goes down one stackframe
> instead).
>
> Save the alias in your .pdbrc file.

Alright. Thanks, Duncan!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "finally" for unit test

2007-03-23 Thread 7stud
On Mar 23, 5:18 am, "killkolor" <[EMAIL PROTECTED]> wrote:
> I have .. a single function that ..
> works with files (takes input and outputs in the same file, no return
> values).

That function could cause problems.  If your function reads in the
whole file, modifies the data, and then overwrites the file, what
would happen if something unforeseen happened and your program crashed
after writing one line to the file?  All the data in memory would go
poof! and your file would contain 1 line it--effectively erasing the
entire contents of the file.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exit to interpreter?

2007-03-23 Thread kyosohma
On Mar 23, 12:52 pm, belinda thom <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm writing a function that polls the user for keyboard input,
> looping until it has determined that the user has entered a valid
> string of characters, in which case it returns that string so it can
> be processed up the call stack. My problem is this. I'd also like it
> to handle a special string (e.g. 'quit'), in which case control
> should return to the Python command line as opposed to returning the
> string up the call stack.
>
> sys.exit seemed like a good choice, but it exits the python interpreter.
>
> I could use an exception for this purpose, but was wondering if
> there's a better way?
>
> --b

If you're using a function, wouldn't using the keyword "return" work?

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exit to interpreter?

2007-03-23 Thread belinda thom

On Mar 23, 2007, at 11:04 AM, [EMAIL PROTECTED] wrote:

> On Mar 23, 12:52 pm, belinda thom <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I'm writing a function that polls the user for keyboard input,
>> looping until it has determined that the user has entered a valid
>> string of characters, in which case it returns that string so it can
>> be processed up the call stack. My problem is this. I'd also like it
>> to handle a special string (e.g. 'quit'), in which case control
>> should return to the Python command line as opposed to returning the
>> string up the call stack.
>>
>> sys.exit seemed like a good choice, but it exits the python  
>> interpreter.
>>
>> I could use an exception for this purpose, but was wondering if
>> there's a better way?
>>
>> --b
>
> If you're using a function, wouldn't using the keyword "return" work?
>
> Mike

No, because that just returns to the caller, which is not the Python  
interpreter.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: On Java's Interface (the meaning of interface in computer programing)

2007-03-23 Thread John W. Kennedy
Lew wrote:
> But if Xah were being trollish, why didn't they jump on my response and 
> call me names?

I'm not sure he's a proper troll. Unfortunately, he seems to be the kind 
of person who thinks that reading "Java for Dummies" makes one a 
self-sufficient expert on Java and philosopher of programming languages 
to boot, and who is very eager to bestow upon the world all his 
brilliant insights.

At least, that explanation is consistent with his historic behavior.

-- 
John W. Kennedy
"Only an idiot fights a war on two fronts.  Only the heir to the throne 
of the kingdom of idiots would fight a war on twelve fronts"
  -- J. Michael Straczynski.  "Babylon 5", "Ceremonies of Light and Dark"
* TagZilla 0.066 * http://tagzilla.mozdev.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multi-line strings with formatting

2007-03-23 Thread Steve Holden
Carsten Haese wrote:
> On Fri, 2007-03-23 at 09:54 -0700, [EMAIL PROTECTED] wrote:
>> When constructing a particularly long and complicated command to be
>> sent to the shell, I usually do something like this, to make the
>> command as easy as possible to follow:
>>
>> commands.getoutput(
>> 'mycommand -S %d -T %d ' % (s_switch, t_switch)   +
>> '-f1 %s -f2 %s ' % (filename1, filename2) +
>> '> %s'   % (log_filename)
>> )
>>
>> Can anyone suggest a better way to construct the command, especially
>> without the "+" sign at the end of each line (except the last) ? If I
>> take out the "+", then I need to move all the variables to the end, as
>> so:
>>
>> commands.getoutput(
>> 'mycommand -S %d -T %d '
>> '-f1 %s -f2 %s '
>> '> %s'
>> % (s_switch, t_switch, filename1, filename2, log_filename)
>> )
>>
>> or:
>>
>> commands.getoutput(
>> '''mycommand -S %d -T %d \
>> -f1 %s -f2 %s \
>> > %s'''
>> % (s_switch, t_switch, filename1, filename2, log_filename)
>> )
> 
> You get the best of both worlds, i.e. one big multiline string with
> in-line parameters, by using a mapping:
> 
> commands.getoutput(
>'''mycommand -S %(s_switch)d -T %(t_switch)d \
> -f1 %(filename1)s -f2 %(filename2)s \
> > %(log_filename)s'''
> % locals() )
> 
> Of course I'm assuming that s_switch etc. are local variables. If
> they're not, well, they ought to be.
> 
> -Carsten
> 
> 
If that doesn't suit then build a list:

l = [
 'mycommand -S %d -T %d ' % (s_switch, t_switch)   ,
 '-f1 %s -f2 %s ' % (filename1, filename2) ,
 '> %s'   % (log_filename)
]

and then return commands.getoutput("".join(l)).

regards
  Steve

-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings   http://holdenweb.blogspot.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: #!/usr/bin/env python > 2.4?

2007-03-23 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Gabriel Genellina wrote:
> Uh... I never thought it was an implied formula there - that F0 had to  
> come from 1.5 = 15 = 0xF.
> I think it should be stated much more clearly.

I'm not sure what you're saying. You are correct that the
documentation is rather vague. The 'f0' comes from 'final release'
I think.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Still the __new__ hell ...

2007-03-23 Thread Paulo da Silva
Gabriel Genellina escreveu:
> En Wed, 21 Mar 2007 07:51:32 -0300, Bruno Desthuilliers
> <[EMAIL PROTECTED]> escribió:
> 
>> Paulo da Silva a écrit :
>>> As a relatively inexperient
>>> in python, how could I know that a 'string' is an instance of
>>> basestring?
>>
>> By reading this newsgroup ?-)
> 
> Or asking Python itself:
> 
 type("any string").mro()
> [, , ]
> 
> --Gabriel Genellina
> 

Good! ;-)
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Join strings - very simple Q.

2007-03-23 Thread Paulo da Silva
Hi!

I was told in this NG that string is obsolet. I should use
str methods.

So, how do I join a list of strings delimited by a given
char, let's say ','?

Old way:

l=['a','b','c']
jl=string.join(l,',')

New way?

Thanks
Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paul Rudin
Paulo da Silva <[EMAIL PROTECTED]> writes:

> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?

Dunno if it's the "new way", but you can do: ''.join(l)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Mike Kent
On Mar 23, 2:37 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?
>
> Thanks
> Paulo

New way:
l=['a','b','c']
jl=','.join(l)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paul Rudin
Paul Rudin <[EMAIL PROTECTED]> writes:

> Paulo da Silva <[EMAIL PROTECTED]> writes:
>
>> Hi!
>>
>> I was told in this NG that string is obsolet. I should use
>> str methods.
>>
>> So, how do I join a list of strings delimited by a given
>> char, let's say ','?
>>
>> Old way:
>>
>> l=['a','b','c']
>> jl=string.join(l,',')
>>
>> New way?
>
> Dunno if it's the "new way", but you can do: ''.join(l)

Err, sorry - missed the comma out - it should be: ','.join(l)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Daniel Nogradi
> > I was told in this NG that string is obsolet. I should use
> > str methods.
> >
> > So, how do I join a list of strings delimited by a given
> > char, let's say ','?
> >
> > Old way:
> >
> > l=['a','b','c']
> > jl=string.join(l,',')
> >
> > New way?
>
> Dunno if it's the "new way", but you can do: ''.join(l)

The OP wants the strings to be comma delimited:

jl=','.join(l)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to receive a FILE* from Python under MinGW?

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 10:07:30 -0300, John Pye <[EMAIL PROTECTED]> escribió:

> On Mar 23, 7:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>>
>> And replace all places where a Python file goes into a C extension, with
>> exportable_file(f)
>
> What about calling mscvrt_get_osfhandle from inside the SWIG wrapper?
> I tried this but it seemed that the function was not exported to the
> DLL.

The idea is to separate both worlds - _get_osfhandle must be called from  
the C runtime used by Python, not the one linked to your extension.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


ECCOMAS Thematic Conference VipIMAGE 2007 - Last Call for Papers

2007-03-23 Thread [EMAIL PROTECTED]
-

(Apologies for cross-posting)

International ECCOMAS Thematic Conference VipIMAGE 2007 - I ECCOMAS
THEMATIC
CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING
17-19th October 2007, FEUP, Porto, Portugal
http://www.fe.up.pt/VIPIMAGE

We would appreciate if you could distribute this information by your
colleagues and co-workers.

-

Dear Colleague,

The International Conference VipIMAGE - I ECCOMAS THEMATIC CONFERENCE
ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING will be held in
the Faculty of Engineering of University of Porto, Porto, Portugal, on
October 17-19, 2007.

VipIMAGE will bring together several researchers from around the world
representing several fields of study related to Computational Vision
and Medical Image Processing, such as: Physics of Medical Imaging;
Signal and image Processing; Simulation and Modelling; Data
Interpolation, Registration and Compression; Telemedicine; Computer
Aided Diagnosis, Surgery, Therapy, and Treatment; Computational
Bioimaging and Visualization; Software Development and Grid Computing.

The organizers would like to invite you to submit your contributions
for VipIMAGE until the end of March.

More details can be found in the conference website: 
http://www.fe.up.pt/VIPIMAGE.

Important dates

Submission of extended abstracts: March 31, 2007;
Authors Notification: April 15, 2007;
Lectures and Final Papers: May 15, 2007;
Early registration fee: May 31, 2007.

Proceedings

The proceedings book of VipIMAGE will be will published by the Taylor
& Francis Group.

Invited Lectures

- Automatic Generation of Computer Models from Multi-modal Bio-medical
Imaging - Chandrajit Bajaj, USA
- Computational Bioimaging and Visualization - Chris Johnson, USA
- From Geometrical Models to Physiological Models of the Human Body -
Hervé Delingette, France
- Latest advances in Cardiovascular Informatics - Ioannis A.
Kakadiaris, USA
- Robust Algorithms for Deformable Contours - Jorge S. Marques,
Portugal
- Image Sequence Evaluation - Juan J. Villanueva, Spain
- Fast Surface Segmentation and remeshing by finding geodesics -
Laurent Cohen, France
- Processing of Simultaneous acquisition of EEG and fMRI - Mario
Forjaz Secca, Portugal
- Automatic Construction of Statistical Shape Models using Non-Rigid
Registration - Tim Cootes, UK
- Theory of Digital Manifolds and its Applications to Medical Imaging
- Valentin Brimkov, USA & Reinhard Klette, NZ


We are looking forward to host you in Porto next October.

Kind regards,

João Manuel R. S. Tavares
Renato Natal Jorge
(conference co-chairs)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread Paulo da Silva
Mike Kent escreveu:
...

> New way:
> l=['a','b','c']
> jl=','.join(l)
> 

I thank you all.

Almost there ...
I tried "".join(l,',') but no success ... :-(

Paulo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to receive a FILE* from Python under MinGW?

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 16:34:22 -0300, Gabriel Genellina  
<[EMAIL PROTECTED]> escribió:

>> What about calling mscvrt_get_osfhandle from inside the SWIG wrapper?
>> I tried this but it seemed that the function was not exported to the
>> DLL.
>
> The idea is to separate both worlds - _get_osfhandle must be called from  
> the C runtime used by Python, not the one linked to your extension.

Ah, but you could import the msvcrt module and get it from there. *ONLY*  
get_osfhandle. The other function, open_osfhandle, must be from the  
runtime used by your extension.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exit to interpreter?

2007-03-23 Thread Mel Wilson
belinda thom wrote:
> On Mar 23, 2007, at 11:04 AM, [EMAIL PROTECTED] wrote:
> 
>> On Mar 23, 12:52 pm, belinda thom <[EMAIL PROTECTED]> wrote:
>>> Hi,
>>>
>>> I'm writing a function that polls the user for keyboard input,
>>> looping until it has determined that the user has entered a valid
>>> string of characters, in which case it returns that string so it can
>>> be processed up the call stack. My problem is this. I'd also like it
>>> to handle a special string (e.g. 'quit'), in which case control
>>> should return to the Python command line as opposed to returning the
>>> string up the call stack.
>>>
>>> sys.exit seemed like a good choice, but it exits the python  
>>> interpreter.
>>>
>>> I could use an exception for this purpose, but was wondering if
>>> there's a better way?

A custom-defined exception is probably the best way to jump out of a 
stack of nested calls.


Mel.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exit to interpreter?

2007-03-23 Thread kyosohma
On Mar 23, 1:20 pm, belinda thom <[EMAIL PROTECTED]> wrote:
> On Mar 23, 2007, at 11:04 AM, [EMAIL PROTECTED] wrote:
>
>
>
> > On Mar 23, 12:52 pm, belinda thom <[EMAIL PROTECTED]> wrote:
> >> Hi,
>
> >> I'm writing a function that polls the user for keyboard input,
> >> looping until it has determined that the user has entered a valid
> >> string of characters, in which case it returns that string so it can
> >> be processed up the call stack. My problem is this. I'd also like it
> >> to handle a special string (e.g. 'quit'), in which case control
> >> should return to the Python command line as opposed to returning the
> >> string up the call stack.
>
> >> sys.exit seemed like a good choice, but it exits the python
> >> interpreter.
>
> >> I could use an exception for this purpose, but was wondering if
> >> there's a better way?
>
> >> --b
>
> > If you're using a function, wouldn't using the keyword "return" work?
>
> > Mike
>
> No, because that just returns to the caller, which is not the Python
> interpreter.

Sorry...I didn't realize you were calling from another function or
functions. Duh. I agree with the other writer. Use a custom exception.

-- 
http://mail.python.org/mailman/listinfo/python-list


Using Python to start SNMP service on remote XP hosts...

2007-03-23 Thread KDawg44
Hi,

I am very new to Python and really just began studying and using it.
I read that it was relatively easy to interact with Windows machines
with Python and I am desperately looking for something to replace
VBScript (not a big fan).

I am currently deploying a Gentoo Linux SNMP server running Cacti in
my network and would like my XP machines to report traps to this box.
The SNMP service is not running by default on the machines in the
network and instead of going to each one at a time, I thought I could
write a script.

Does anyone have any suggestions about how I go about accomplishing
this?

Thanks so much for any suggestions.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Join strings - very simple Q.

2007-03-23 Thread John Machin
On Mar 24, 5:37 am, Paulo da Silva <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I was told in this NG that string is obsolet. I should use
> str methods.
>
> So, how do I join a list of strings delimited by a given
> char, let's say ','?
>
> Old way:
>
> l=['a','b','c']
> jl=string.join(l,',')
>
> New way?
>

Self-help #1: reading the documentation: 
http://www.python.org/doc/2.0/lib/string-methods.html
?
Change "0" to "5" to get the latest released version -- which hasn't
changed the description of the join method AFAICT.

Self-help #2: help() at the interactive prompt:

Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
| >>> help("".join)
Help on built-in function join:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence.  The separator between elements is S.

| >>>

OK, I'll bite: This was "new" in late 2000 when Python 2.0 was
released. Where have you been in the last ~6.5 years?

HTH,
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python to start SNMP service on remote XP hosts...

2007-03-23 Thread kyosohma
On Mar 23, 2:51 pm, "KDawg44" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am very new to Python and really just began studying and using it.
> I read that it was relatively easy to interact with Windows machines
> with Python and I am desperately looking for something to replace
> VBScript (not a big fan).
>
> I am currently deploying a Gentoo Linux SNMP server running Cacti in
> my network and would like my XP machines to report traps to this box.
> The SNMP service is not running by default on the machines in the
> network and instead of going to each one at a time, I thought I could
> write a script.
>
> Does anyone have any suggestions about how I go about accomplishing
> this?
>
> Thanks so much for any suggestions.

It looks like you can use Tim Golden's WMI module to do what you need.
See this other post for info:
http://www.thescripts.com/forum/thread541366.html

You'll have to find out the exact name of the service, loop through
and use an IF to test for it and when it is found, try starting it.

Mike

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create new processes over telnet in XP

2007-03-23 Thread Laurent Pointal
Jorgen Grahn wrote:

> On 23 Mar 2007 03:47:14 -0700, Godzilla <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> How do you create/spawn new processes in XP over telnet using python?
>> I.e. I would like to create a new process and have it running in the
>> background...
> 
> Ssh -- or even rsh -- are better choices than telnet for these things.
> For some reason, they are not standard in Windows, though.
> 
>   ssh somewhere some command with arguments
>   rsh somewhere some command with arguments
> 
> compared to
> 
>   telnet somewhere
> 
> and then performing expect-like things (basically simulating
> someone typing "some command with arguments" in the telnet
> session).

+ for an sshd running as a service under XP, look at CopSSH.

+ hope started process doesn't want a GUI... else, look at UltraVNC running
as daemon, and port redirection using ssh.

> 
>> when I terminate the telnet connection, I would what the
>> spawned processes to keep running until I shut it off...
> 
> That's a function of the remote OS; what happens when its terminal
> goes away is not under the control of the client side.

Maybe the process starting job can be done by a Python program running as
Windows service and waiting for requests on a port (or Pyro object or Corba
object...). 
No need for telnet/ssh connection, no logout problem.

Just care of possible security problems :-) 



-- 
http://mail.python.org/mailman/listinfo/python-list


Python object overhead?

2007-03-23 Thread Matt Garman
I'm trying to use Python to work with large pipe ('|') delimited data
files.  The files range in size from 25 MB to 200 MB.

Since each line corresponds to a record, what I'm trying to do is
create an object from each record.  However, it seems that doing this
causes the memory overhead to go up two or three times.

See the two examples below: running each on the same input file
results in 3x the memory usage for Example 2.  (Memory usage is
checked using top.)

This happens for both Python 2.4.3 on Gentoo Linux (64bit) and Python
2.3.4 on CentOS 4.4 (64bit).

Is this "just the way it is" or am I overlooking something obvious?

Thanks,
Matt


Example 1: read lines into list:
# begin readlines.py
import sys, time
filedata = list()
file = open(sys.argv[1])
while True:
line = file.readline()
if len(line) == 0: break # EOF
filedata.append(line)
file.close()
print "data read; sleeping 20 seconds..."
time.sleep(20) # gives time to check top
# end readlines.py


Example 2: read lines into objects:
# begin readobjects.py
import sys, time
class FileRecord:
def __init__(self, line):
self.line = line
records = list()
file = open(sys.argv[1])
while True:
line = file.readline()
if len(line) == 0: break # EOF
rec = FileRecord(line)
records.append(rec)
file.close()
print "data read; sleeping 20 seconds..."
time.sleep(20) # gives time to check top
# end readobjects.py
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: wxPython 2.8.3.0

2007-03-23 Thread Robin Dunn
Announcing
--

The 2.8.3.0 release of wxPython is now available for download at
http://wxpython.org/download.php.  This release includes a number of
bug fixes and also some new enhancements, including updates to the
XRCed tool and the new InspectionTool.

Source code is available, as well as binaries for both Python 2.4 and
2.5, for Windows and Mac, as well some pacakges for various Linux
distributions.  A summary of changes is listed below and also at
http://wxpython.org/recentchanges.php.


What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most
cases the native widgets are used on each platform to provide a 100%
native look and feel for the application.


Changes in 2.8.3.0
--

Added wx.ToolBar.SetToolNormalBitmap and SetToolDisabledBitmap
methods.  (Keep in mind however that the disabled bitmap is currently
generated on the fly by most native toolbar widgets, so this
SetToolDisabledBitmap method won't have any affect on them...)

Refactored the inspection tool such that it can be used as a wx.App
mix-in class as it was used before (with the wx.lib.mixins.inspect
module) and also as a non mix-in tool (using 
wx.lib.inspect.InspectionTool).

Add wx.lib.mixins.treemixin from Frank Niessink.

Added the wx.SizerFlags class, and also added AddF, InsertF and
PrependF methods to wx.Sizer.  The wxSizerFlags class provides a
convienient and easier to read way to add items to a sizer.  It was
added as a new set of methods of the wx.Sizer class so as to not
disturb existing code.  For example, instead of writing::

 sizer.Add(ctrl, 0, wx.EXPAND | wx.ALL, 10)

you can now write::

 sizer.AddF(ctrl, wx.SizerFlags().Expand().Border(wx.ALL,10))


Will Sadkin provided a patch for the wx.lib.masked package that fixes
its support for using the navigation keys on the numeric keypad.

wx.lib.plot: patch #1663937 to allow user to turn off scientific
notation on plot.

wxGTK: Most of the remaining TODOs for the wx.GraphicsContext on wxGTK
have been done.  This includes implementations for GetTextExtent,
Clip, DrawBitmap, fixing the drawing position of text to be at the
upper left corner instead of the baseline, etc.

wx.lib.customtreectrl patches from Andrea:

   1. ExpandAll has been renamed as ExpandAllChildren, and the new
  ExpandAll now takes no input arguments (consistent with
  wx.TreeCtrl)

   2. ctstyle keyword is now defaulted to 0: every style related to
  CustomTreeCtrl and the underlying wx.PyScrolledWindow should be
  declared using the keyword "style" only. For backward
  compatibility, ctstyle continues to work as I merged ctstyle and
  style in the __init__ method.

   3. GetClassDefaultAttributes is now a classmethod.

   4. UnselectAll bug fixed.


Renamed the wx.lib.inspect and wx.lib.mixins.inspect modules to
inspection, in order to avoid conflicts with the inspect module in the
standard Python library.

Lots of changes to XRCed from Roman Rolinsky:


   * Preferences for default "sizeritem" parameters for new panels and
 controls can be configured ("File">"Preferences...").

   * Implemented comment object for including simple one-line comments
 and comment directives as tree nodes. No validation is performed
 for a valid XML string so comments must not contain "-->". Comment
 directive is a special comment starting with '%' character,
 followed by a line of python code. It is executed using 'exec'
 when the resource file is opened. This is useful to import plugin
 modules containing custom handlers which are specific to the
 resource file, hovewer this is of course a security hole if you
 use foreign XRC files. A warning is displayed if the preference
 option 'ask' is selected (by default).

   * Added support for custom controls and plugin modules. Refer to
 this wxPythonWiki for the details:
 http://wiki.wxpython.org/index.cgi/XRCed#custom

   * Tool panel sections can be collapsed/expanded by clicking on the
 label of a tool group.

   * Some undo/redo and other fixes.

   * Fixes for wxMSW (notebook highlighting, control sizes, tree
 Unselect).

   * Notebook page highlighting fix. Highlight resizes when the window
 is resized. ParamUnit spin button detects event handler re-entry
 (wxGTK probably has a bug in wxSpinButton with repeated events).

   * Fix for dealing with empty 'growable' property, u

Re: Python object overhead?

2007-03-23 Thread Mark Nenadov
On Fri, 23 Mar 2007 15:11:35 -0600, Matt Garman wrote:


> 
> Is this "just the way it is" or am I overlooking something obvious?
> 


Matt,

If you iterate over even the smallest object instantiation a large amount
of times, it will be costly compared to a simple list append.

I don't think you can get around some overhead with the objects.

However, in terms of generally efficiency not specifically related to
object instantiation, you should look into xreadlines().

I'd suggest doing the following instead of that while loop: 

for line in open(sys.argv[1]).xreadlines():
  ..


-- 
Mark Nenadov -> skype: marknenadov, web: http://www.marknenadov.com
-> "Glory is fleeting, but obscurity is forever." -- Napoleon Bonapart

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create new processes over telnet in XP

2007-03-23 Thread Shane Geiger
This reminds me of something I once wanted to do:  How can I install 
Python in a totally non-gui way on Windows (without the use of VNC)?  I 
think I was telnetted into a computer (or something like that) and I was 
unable to run the usual Python installer because it uses a GUI.






Laurent Pointal wrote:

Jorgen Grahn wrote:

  

On 23 Mar 2007 03:47:14 -0700, Godzilla <[EMAIL PROTECTED]> wrote:


Hello,

How do you create/spawn new processes in XP over telnet using python?
I.e. I would like to create a new process and have it running in the
background...
  

Ssh -- or even rsh -- are better choices than telnet for these things.
For some reason, they are not standard in Windows, though.

  ssh somewhere some command with arguments
  rsh somewhere some command with arguments

compared to

  telnet somewhere

and then performing expect-like things (basically simulating
someone typing "some command with arguments" in the telnet
session).



+ for an sshd running as a service under XP, look at CopSSH.

+ hope started process doesn't want a GUI... else, look at UltraVNC running
as daemon, and port redirection using ssh.

  

when I terminate the telnet connection, I would what the
spawned processes to keep running until I shut it off...
  

That's a function of the remote OS; what happens when its terminal
goes away is not under the control of the client side.



Maybe the process starting job can be done by a Python program running as
Windows service and waiting for requests on a port (or Pyro object or Corba
object...). 
No need for telnet/ssh connection, no logout problem.


Just care of possible security problems :-) 




  


--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python object overhead?

2007-03-23 Thread Jack Diederich
On Fri, Mar 23, 2007 at 03:11:35PM -0600, Matt Garman wrote:
> I'm trying to use Python to work with large pipe ('|') delimited data
> files.  The files range in size from 25 MB to 200 MB.
> 
> Since each line corresponds to a record, what I'm trying to do is
> create an object from each record.  However, it seems that doing this
> causes the memory overhead to go up two or three times.
> 
> See the two examples below: running each on the same input file
> results in 3x the memory usage for Example 2.  (Memory usage is
> checked using top.)
[snip]

When you are just appending all the lines in a big list your overhead
looks like:

records = []
for line in file_ob:
  records.append(line)

But when you wrap each line in a small class the overhead is

records = []
for line in file_ob:
  records.append(line) # the actual string
  records.append(object()) # allocation for the object instance
  records.append({}) # dictionary for per instance attributes

For small strings like dictionary words the overhead over the second
is about 5x the overhead of a plain list.  Most of it is the per
instance dictionary.

If you make the record a new style class (inherit from object) you can
specify the __slots__ attribute on the class.  This eliminates the per
instance dictionary overhead in exchange for less flexibility.

Another solution would be to only wrap the lines as they are accessed.
Make one class that holds a collection of raw records.  Have that return
a fancy class wrapping each record right before it is used and discarded.

class RecordCollection(object):
  def __init__(self, raw_records):
self.raw_records = raw_records
  def __getitem__(self, i):
return Record(self.raw_records[i])

If you are operating on each of the records in serial you only have
the class overhead for one at any given time.

Hope that helps,

-Jack
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python object overhead?

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 18:27:25 -0300, Mark Nenadov  
<[EMAIL PROTECTED]> escribió:

> I'd suggest doing the following instead of that while loop:
>
> for line in open(sys.argv[1]).xreadlines():

Poor xreadlines method had a short life: it was born on Python 2.1 and got  
deprecated on 2.3 :(
A file is now its own line iterator:

f = open(...)
for line in f:
   ...

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python object overhead?

2007-03-23 Thread Gabriel Genellina
En Fri, 23 Mar 2007 18:11:35 -0300, Matt Garman <[EMAIL PROTECTED]>  
escribió:

> Example 2: read lines into objects:
> # begin readobjects.py
> import sys, time
> class FileRecord:
> def __init__(self, line):
> self.line = line
> records = list()
> file = open(sys.argv[1])
> while True:
> line = file.readline()
> if len(line) == 0: break # EOF
> rec = FileRecord(line)
> records.append(rec)
> file.close()
> print "data read; sleeping 20 seconds..."
> time.sleep(20) # gives time to check top
> # end readobjects.py

Your file record requires at least two objects in addition to the line  
itself: the FileRecord instance and the dictionary instance (__dict__)  
used to hold its attributes.
You can use a new style class with __slots__ to omit that dictionary:

class FileRecord(object):
 __slots__ = ['line']
 def __init__(self, line):
 self.line = line

or defer instance creation:

class FileRecords(list):
 # store here all the lines, maybe using readlines()
 def __getitem__(self, index):
 return FileRecord(list.__getitem__(self, index))

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


On text processing

2007-03-23 Thread Daniel Nogradi
Hi list,

I'm in a process of rewriting a bash/awk/sed script -- that grew to
big -- in python. I can rewrite it in a simple line-by-line way but
that results in ugly python code and I'm sure there is a simple
pythonic way.

The bash script processed text files of the form:

###
key1value1
key2value2
key3value3

key4value4
spec11  spec12   spec13   spec14
spec21  spec22   spec23   spec24
spec31  spec32   spec33   spec34

key5value5
key6value6

key7value7
more11   more12   more13
more21   more22   more23

key8value8
###

I guess you get the point. If a line has two entries it is a key/value
pair which should end up in a dictionary. If a key/value pair is
followed by consequtive lines with more then two entries, it is a
matrix that should end up in a list of lists (matrix) that can be
identified by the key preceeding it. The empty line after the last
line of a matrix signifies that the matrix is finished and we are back
to a key/value situation. Note that a matrix is always preceeded by a
key/value pair so that it can really be identified by the key.

Any elegant solution for this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: On Java's Interface (the meaning of interface in computer programing)

2007-03-23 Thread Sherm Pendley
Lew <[EMAIL PROTECTED]> writes:

> But if Xah were being trollish, why didn't they jump on my response
> and call me names?

Xah never replies to the threads he starts. At least, I've never known him
to do so.

> I still think that analysis of the original post is a useful exercise
> to learn Java.

Maybe so - I don't know enough Java to comment on that. But there's nothing
useful to cross-posting the original to a fistful of non-Java lists.

> The more subtle Xah or other
> minions of Satan get in their presentations, the more interesting the
> forensic exercise to dig out the truth.

The truth is that Xah wants to start an argument. He cross-posts for that
reason, so that the "forensic exercise" you're speaking of then becomes an
argument among proponents of the various languages about which language is
closer to the "truth".

Don't take my word for it though - check Google Groups. You'll find he's
been doing this for a long time.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fine grain logging cotrol

2007-03-23 Thread Eric S. Johansson
Peter Otten wrote:
> Eric S. Johansson wrote:
> 
> Here is yet another revision of my example then:

it's making more and more sense although I don't quite follow 'property' 
quite yet.  But I see that get_logger is invoked prior to the 
__logger.info call.

I was looking at how to implement one of my other requirements 
(conditional based on a predicate) and I see that I could use a filter. 
I've experimented a little but come up empty.  This is what I changed:

class filter_test (logging.Filter):
 test_names = { "Felis.alpha" : True,
"Catus.alpha" : False,
}

 def ___init__ (self, name):
 """simple filter test """
 self.name = name

 def filter(self, record):
 """test and forget """
 return test_names.has_key(self.name) and test_names[self.name]

class LoggedType(type):
 def __new__(mcl, name, bases, classdict):
 def get_logger(self):
 tag = "%s.%s" % (name,sys._getframe(1).f_code.co_name)
 lgr = logging.getLogger(tag)
 lgr.addFilter(filter_test)
 return lgr

 classdict["_%s__logger" % name] = property(get_logger)
 return type.__new__(mcl, name, bases, classdict)

It's probably real obvious but I keep getting a:

   File "C:\Python24\lib\logging\__init__.py", line 539, in filter
 if not f.filter(record):
TypeError: unbound method filter() must be called with filter_test 
instance as first argument (got LogRecord instance instead)


I'm puzzled that I thought I was adding the filter object at the right 
point in time with addFilter.  I wouldn't be surprised if I was totally 
off base but I'd be interested in figuring out how I went off the rails 
so I can fill in the knowledge.

---eric



-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >