Re: Is there no compression support for large sized strings in Python?

2005-12-03 Thread Fredrik Lundh
Christopher Subich wrote:

 anyone out there with an ILP64 system?

 I have access to an itanium system with a metric ton of memory.  I
 -think- that the Python version is still only a 32-bit python

an ILP64 system is a system where int, long, and pointer are all 64 bits,
so a 32-bit python on a 64-bit platform doesn't really qualify.

/... snip examples that show that python's string handling could need
some work for the len(s)  maxint case .../

/F 



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


Re: advice : how do you iterate with an acc ?

2005-12-03 Thread Ben Finney
[EMAIL PROTECTED] wrote:
 acc = []# accumulator ;)
 for line in fileinput.input():
 if condition(line):
 if acc:#1
 doSomething(acc)#1
 acc = []
 else:
 acc.append(line)
 if acc:#2
 doSomething(acc)#2

Looks like you'd be better off making an Accumulator that knows what
to do.

 class Accumulator(list):
... def flush(self):
... if len(self):
... print Flushing items: %s % self
... del self[:]
...
 lines = [
... spam, eggs, FLUSH,
... beans, rat, FLUSH,
... strawberry,
... ]

 acc = Accumulator()
 for line in lines:
... if line == 'FLUSH':
... acc.flush()
... else:
... acc.append(line)
...
Flushing items: ['spam', 'eggs']
Flushing items: ['beans', 'rat']
 acc.flush()
Flushing items: ['strawberry']


-- 
 \ [W]e are still the first generation of users, and for all that |
  `\ we may have invented the net, we still don't really get it.  |
_o__) -- Douglas Adams |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling Guppy-PE extension modules

2005-12-03 Thread Sverker Nilsson

 Claudio Grondi [EMAIL PROTECTED] wrote:
I don't know if it applies here, but in this context the extern keyword

   comes to my mind.

[snip extracts from Microsoft docs]

Perhaps. But I suspect it isn't that simple since ...
I'd think even if I don't use the extern keyword the compiler
should be able to figure it out. (As a service to the programmer.)
And it shouldn't be very difficult to do.

I'll probably not try this out for a while,
but maybe you can check it yourself or ask someone that knows C.

Regards,


Sverker

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


os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Tony Meyer
On Windows, if I do os.rename(old, new) where old is a file that is
in-use (e.g. python itself, or a dll that is loaded), I would expect
that an error would be raised (e.g. as when os.remove is called with
an in-use file).  However, what happens is that a copy of the file is
made, and the old file still exists.

For example:

C:\c:\python24\python.exe
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
 import os
 import sys
 sys.executable
'c:\\python24\\python.exe'
 os.rename(sys.executable, d:\\python24.exe)
 ^Z

D:\dir c:\python24\p*.exe
 Volume in drive C is ACER
 Volume Serial Number is 320D-180E

 Directory of c:\python24

28/09/2005  12:41 p.m. 4,608 python.exe
28/09/2005  12:41 p.m. 5,120 pythonw.exe
   2 File(s)  9,728 bytes
   0 Dir(s)  16,018,685,952 bytes free

C:\dir d:\p*24.exe
 Volume in drive D is DATA
 Volume Serial Number is 4019-78E0

 Directory of d:\

28/09/2005  12:41 p.m. 4,608 python24.exe
   1 File(s)  4,608 bytes
   0 Dir(s)  15,362,207,744 bytes free

Is this the intended behaviour?  The documentation doesn't give any
indication that it is (so unless I'm missing something, this is at
least a documentation bug).

Any insight appreciated :)  (I do know that I can work around it by
doing a remove after the rename, if the file exists).

=Tony.Meyer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cut and paste an EPS file

2005-12-03 Thread Piet van Oostrum
 John Henry [EMAIL PROTECTED] (JH) wrote:

JH I am looking for a Python tookit that will enable me to cut section of
JH a picture out from an EPS file and create another EPS file.

JH I am using a proprietary package for doing certain engineering
JH calculations.  It creates single page x-y line plots that has too much
JH blank spaces around the plotted area located at the top 2/3 of the
JH page.  I like to be  cut that white space out by extracting the image
JH out and may be scale it up - while keeping the bottom 1/3 unchanged.

If you just want to remove the spurious whitespace (i.e. crop the picture)
you can do this with ghostscript. Look for a script ps2eps.
-- 
Piet van Oostrum [EMAIL PROTECTED]
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Unicode decimal interpretation

2005-12-03 Thread Martin v. Löwis
Scott David Daniels wrote:
 In reading over the source for CPython's PyUnicode_EncodeDecimal,
 I see a dance to handle characters which are neither dec-equiv nor
 in Latin-1.  Does anyone know about the intent of such a conversion?

To support this:

  int(u\N{DEVANAGARI DIGIT SEVEN})
7


 As far as I can tell, error handling is one of:
 strict, replace, ignore, xmlcharrefreplace, or something_else
 What I don't understand is whether, in the ignore or something_else
 cases, there is any chance that digits will show up anywhere that
 they would not if these characters were treated as a character like '?'?
 
 Can someone either give me definitive why not or (preferably) give
 me a test case that shows where that interpretation does not hold.

In the ignore case, no output is produced at all, for the unencodable
character; this is the same way that '?' would be treated (it is
also unencodable).

In the something_else case, a user-defined exception handler could
treat the error in any way it liked, e.g. encoding all letters
u'A' to digit '0'. This might be different from the way this error
handler would treat '?'.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: XML and namespaces

2005-12-03 Thread and-google
Uche [EMAIL PROTECTED] wrote:

 Of course.  Minidom implements level 2 (thus the NS at the end of the
 method name), which means that its APIs should all be namespace aware.
 The bug is that writexml() and thus toxml() are not so.

Not exactly a bug - DOM Level 2 Core 1.1.8p2 explicitly leaves
namespace fixup at the mercy of the application. It's only standardised
as a DOM feature in Level 3, which minidom does not yet claim to
support. It would be a nice feature to add, but it's not entirely
trivial to implement, especially when you can serialize a partial DOM
tree.

Additionally, it might have some compatibility problems with apps that
don't expect namespace declarations to automagically appear. For
example, perhaps, an app dealing with HTML that doesn't want spare
xmlns=http://www.w3.org/1999/xhtml; declarations appearing in every
snippet of serialized output.

So it should probably be optional. In DOM Level 3 (and pxdom) there's a
DOMConfiguration parameter 'namespaces' to control it; perhaps for
minidom an argument to toxml() might be best?

-- 
And Clover
mailto:[EMAIL PROTECTED]
http://www.doxdesk.com/

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


Re: os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Martin v. Löwis
Tony Meyer wrote:
 Is this the intended behaviour?

Sort-of. os.rename invokes the C library's rename, and does whatever
this does. It is expected that most platform's C libraries do what
the documentation says rename does, but platforms may vary in their
implementation of the C library, and from one compiler version to
the other.

Microsoft's documentation of rename/_rename/_wrename is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_rename.2c_._wrename.asp

It doesn't say anything about renaming in-use files, either.
Looking at the implementation of _rename, I see that it directly
calls MoveFile, which is documented here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/movefile.asp

That doesn't mention the in-use case, either.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Tony Meyer
[Tony Meyer]
 Is this the intended behaviour?

 [Martin v. Löwis]
 Sort-of. os.rename invokes the C library's rename, and does whatever
 this does. It is expected that most platform's C libraries do what
 the documentation says rename does, but platforms may vary in their
 implementation of the C library, and from one compiler version to
 the other.
[snip links to Microsoft documentation, which don't cover the in-use  
case]

Thanks for that.  In your opinion, would a documentation patch that  
explained that this would occur on Windows (after the existing note  
about the Windows rename not being atomic) be acceptable?

(The Windows platform C library for Python 2.4+ is in msvcrt71.dll,  
right?  Does that mean that behaviour will be consistent across  
Windows versions, or could 9x/NT/XP/etc all behave differently?)

=Tony.Meyer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advice : how do you iterate with an acc ?

2005-12-03 Thread Bengt Richter
On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:


Bengt Richter wrote:
 It looks to me like itertools.groupby could get you close to what you want,
 e.g., (untested)
Ah, groupby. The generic string.split() equivalent. But the doc said
the input needs to be sorted.


  seq = [3,1,4,'t',0,3,4,2,'t',3,1,4]
  import itertools
  def condition(item): return item=='t'
 ...
  def dosomething(it): return 'doing something with %r'%list(it)
 ...
  for condresult, acciter in itertools.groupby(seq, condition):
 ... if not condresult:
 ... dosomething(acciter)
 ...
 'doing something with [3, 1, 4]'
 'doing something with [0, 3, 4, 2]'
 'doing something with [3, 1, 4]'

I think the input only needs to be sorted if you a trying to group sorted 
subsequences of the input.
I.e., you can't get them extracted together unless the condition is satisfied 
for a contiguous group, which
only happens if the input is sorted. But AFAIK the grouping logic just scans 
and applies key condition
and returns iterators for the subsequences that yield the same key function 
result, along with that result.
So it's a general subsequence extractor. You just have to supply the key 
function to make the condition value
change when a group ends and a new one begins. And the value can be arbitrary, 
or just toggle beween two values, e.g.

  for condresult, acciter in itertools.groupby(range(20), lambda x:x%3==0 or 
  x==5):
 ... print '%6s: %r'%(condresult, list(acciter))
 ...
   True: [0]
  False: [1, 2]
   True: [3]
  False: [4]
   True: [5, 6]
  False: [7, 8]
   True: [9]
  False: [10, 11]
   True: [12]
  False: [13, 14]
   True: [15]
  False: [16, 17]
   True: [18]
  False: [19]

or a condresult that stays the same in groups, but every group result is 
different:

  for condresult, acciter in itertools.groupby(range(20), lambda x:x//3):
 ... print '%6s: %r'%(condresult, list(acciter))
 ...
  0: [0, 1, 2]
  1: [3, 4, 5]
  2: [6, 7, 8]
  3: [9, 10, 11]
  4: [12, 13, 14]
  5: [15, 16, 17]
  6: [18, 19]

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advice : how do you iterate with an acc ?

2005-12-03 Thread bonono

Bengt Richter wrote:
 On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:

 
 Bengt Richter wrote:
  It looks to me like itertools.groupby could get you close to what you want,
  e.g., (untested)
 Ah, groupby. The generic string.split() equivalent. But the doc said
 the input needs to be sorted.
 

   seq = [3,1,4,'t',0,3,4,2,'t',3,1,4]
   import itertools
   def condition(item): return item=='t'
  ...
   def dosomething(it): return 'doing something with %r'%list(it)
  ...
   for condresult, acciter in itertools.groupby(seq, condition):
  ... if not condresult:
  ... dosomething(acciter)
  ...
  'doing something with [3, 1, 4]'
  'doing something with [0, 3, 4, 2]'
  'doing something with [3, 1, 4]'

 I think the input only needs to be sorted if you a trying to group sorted 
 subsequences of the input.
 I.e., you can't get them extracted together unless the condition is satisfied 
 for a contiguous group, which
 only happens if the input is sorted. But AFAIK the grouping logic just scans 
 and applies key condition
 and returns iterators for the subsequences that yield the same key function 
 result, along with that result.
 So it's a general subsequence extractor. You just have to supply the key 
 function to make the condition value
 change when a group ends and a new one begins. And the value can be 
 arbitrary, or just toggle beween two values, e.g.

   for condresult, acciter in itertools.groupby(range(20), lambda x:x%3==0 
 or x==5):
  ... print '%6s: %r'%(condresult, list(acciter))
  ...
True: [0]
   False: [1, 2]
True: [3]
   False: [4]
True: [5, 6]
   False: [7, 8]
True: [9]
   False: [10, 11]
True: [12]
   False: [13, 14]
True: [15]
   False: [16, 17]
True: [18]
   False: [19]

 or a condresult that stays the same in groups, but every group result is 
 different:

   for condresult, acciter in itertools.groupby(range(20), lambda x:x//3):
  ... print '%6s: %r'%(condresult, list(acciter))
  ...
   0: [0, 1, 2]
   1: [3, 4, 5]
   2: [6, 7, 8]
   3: [9, 10, 11]
   4: [12, 13, 14]
   5: [15, 16, 17]
   6: [18, 19]

Thanks. So it basically has an internal state storing the last
condition result and if it flips(different), a new group starts.

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


Re: os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Bengt Richter
On Sat, 3 Dec 2005 22:32:22 +1300, Tony Meyer [EMAIL PROTECTED] wrote:

On Windows, if I do os.rename(old, new) where old is a file that is
in-use (e.g. python itself, or a dll that is loaded), I would expect
that an error would be raised (e.g. as when os.remove is called with
an in-use file).  However, what happens is that a copy of the file is
made, and the old file still exists.

For example:

C:\c:\python24\python.exe
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on wi=
n32
Type help, copyright, credits or license for more information.
 import os
 import sys
 sys.executable
'c:\\python24\\python.exe'
 os.rename(sys.executable, d:\\python24.exe)
 ^Z

D:\dir c:\python24\p*.exe
 Volume in drive C is ACER
 Volume Serial Number is 320D-180E

 Directory of c:\python24

28/09/2005  12:41 p.m. 4,608 python.exe
28/09/2005  12:41 p.m. 5,120 pythonw.exe
   2 File(s)  9,728 bytes
   0 Dir(s)  16,018,685,952 bytes free

C:\dir d:\p*24.exe
 Volume in drive D is DATA
 Volume Serial Number is 4019-78E0

 Directory of d:\

28/09/2005  12:41 p.m. 4,608 python24.exe
   1 File(s)  4,608 bytes
   0 Dir(s)  15,362,207,744 bytes free

Is this the intended behaviour?  The documentation doesn't give any
indication that it is (so unless I'm missing something, this is at
least a documentation bug).

Any insight appreciated :)  (I do know that I can work around it by
doing a remove after the rename, if the file exists).

Seems like os.rename may be trying to be too helpful

(windows NT4)
 [ 3:26] C:\pywk\grammarhelp ren
 Renames a file or files.

 RENAME [drive:][path]filename1 filename2.
 REN [drive:][path]filename1 filename2.

 Note that you cannot specify a new drive or path for your destination file.

 [ 3:26] C:\pywk\grammarpy24
 Python 2.4b1 (#56, Nov  3 2004, 01:47:27)
 [GCC 3.2.3 (mingw special 20030504-1)] on win32
 Type help, copyright, credits or license for more information.
  import os
  help(os.rename)
 Help on built-in function rename in module nt:

 rename(...)
 rename(old, new)

 Rename a file or directory.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Martin v. Löwis
Tony Meyer wrote:
 Thanks for that.  In your opinion, would a documentation patch that  
 explained that this would occur on Windows (after the existing note  
 about the Windows rename not being atomic) be acceptable?

In principle, yes. We cannot do that for every platform, of course,
but it probably won't be necessary for any platform, either.

 (The Windows platform C library for Python 2.4+ is in msvcrt71.dll,  
 right?  Does that mean that behaviour will be consistent across  Windows 
 versions, or could 9x/NT/XP/etc all behave differently?)

The behaviour could be different in principle, yes. I found a KB article
that says that MoveFile, on Windows CE 4.0, on a FAT file system, would
move the file even if it was open.

I'm actually also surprised by the behaviour - I would have expected
that the failure to delete the file after the copy would cause an
error, or that the attempt to open the file with FILE_SHARE_DELETE
would cause an error right away.

Somebody should investigate this with Sysinternal's filemon, to find
out whether the MoveFile operation really succeeds. Perhaps there is
a bug in the CRT, or in Python, also.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI and long running job

2005-12-03 Thread jmdeschamps

[EMAIL PROTECTED] wrote:
 Hello,
 I am using python and CGI to initiate a long running simulation (up to
 5h long) on a remote machine. The main idea is that I use a form, enter
 the parameters and a CGI scripts start the simulation using these
 parameters. The structure of the script is:

 1. Read paremeters
 2. Display some information
 3. Start the simulation

 For step 3 I use either os.system or os.popen(2). The problem is that
 the web server does not send the information of step 2 back to the
 browser, unless step 3 is completed. The browser simply waits for a
 response, without displaying anything. How can I just read the params,
 display the info I want, start the simulation and then terminate either
 the script or at least the connection to the browser without having to
 wait for the simulation to finish?

 I am using activestate python 2.4, Apache and WinXP.

 Thanks a lot for your help.

Maybe you could use 'os.spawn' variants with the P_NOWAIT parameter...
(not sure of the syntax here, it's in the doc)
Good luck!

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


EOF error

2005-12-03 Thread ash
hi,
when i try to unpickle a pickled file in binary format, i get this
error:

E:\mditest.py
Traceback (most recent call last):
  File E:\mdi\qp.py, line 458, in OnReadButton
data=p.load(file(ques.dat,r))
EOFError

what is the reason? how do i overcome this?
Thanks in advance for you valuable time

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


Re: EOF error

2005-12-03 Thread Peter Otten
ash wrote:

 hi,
 when i try to unpickle a pickled file in binary format, i get this
 error:
 
 E:\mditest.py
 Traceback (most recent call last):
   File E:\mdi\qp.py, line 458, in OnReadButton
 data=p.load(file(ques.dat,r))
 EOFError
 
 what is the reason? how do i overcome this?
 Thanks in advance for you valuable time

You have to open your file in binary mode for both dumping and loading the
data. For that just add a b to the mode parameter, e. g. 

file(ques.dat, rb).

Peter

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


os.chdir + GUI question

2005-12-03 Thread Philippe C. Martin
Hi,

I do not know whether this is a Python, wxPython, Windows, or coding 
question ...

I have a program that changes disk/directory using os.chdir (verified OK 
with os.getcwd) then opens a file dialog box using wx.FileDialog with  
as default dir.

I expected to be in my chdir directory but found myself in the windows 
desktop.

Any clue ?

Regards,

Philippe



-- 
SnakeCard, LLC
Philippe C. Martin
www.snakecard.com


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


[ANN] rpncalc-2.2 RPN Calculator for Python

2005-12-03 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN)
interpreter to Python.  This interpreter allows the use of Python as
an RPN calculator.  You can easily switch between the RPN interpreter
and the standard Python interpreter.

Home page:  http://calcrpnpy.sourceforge.net/

Changes in 2.2

* Display only 12 digits of a mpf or cmpf value.

* Added stats function.

* Added chebyshev module.

* Added solve command.

* Simplified installing user functions into the calculator.

* Added on-line help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.rename copies when old is in-use - is this deliberate?

2005-12-03 Thread Jérôme Laheurte
On Sat, 03 Dec 2005 22:32:22 +1300, Tony Meyer wrote:

 os.rename(sys.executable, d:\\python24.exe)

What happens if you specify a destination file on the same drive as the
source file ?

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


Re: Is Python string immutable?

2005-12-03 Thread Scott David Daniels
Steve Holden wrote:
 could ildg wrote:
 Will string operation in python also leave some garbage? I implemented 
 a net-spider in python which includes many html string procession. 
 After it running for sometime, the python exe eats up over 300M 
 memory. Is this because the string garbages?
  
 If you create garbage in a Python program it will normally be collected 
 and returned to free memory

So far so good -- true for all Pythons.

 by the garbage collector, which should be run when memory is exhausted
  in preference to allocating more memory.

True for Jython, probably true for IronPython (I don't know IronPython
details), definitely not true for CPython.  CPython recycles simply
held memory as the last reference goes away.  In CPython, only when
memory is held in (or by) cyclic structures is the garbage collector
needed to come in and do recycling work.

 Additional memory should therefore only be claimed when garbage 
 collection fails to return sufficient free space.
 
 If cyclic data structures are created (structures in which components 
 refer to each other even though no external references exist) this could 
 cause problems in older versions of Python, but nowadays the garbage 
 collector also takes pains to collect unreferenced cyclic structures.

By older he means substantially older.  If you have a Python = 2.0 you
have no worries, the collector does cycles.  It needs to get to 2.2 or
so before weakrefs are handled correctly.

 * Python 2.4.2 (September 28, 2005)
 * Python 2.4 (November 30, 2004)
 * Python 2.3.5 (February 8, 2005)
 * Python 2.2.3 (May 30, 2003)
 * Python 2.1.3 (April 8, 2002)
 * Python 2.0.1 (June 2001)
 * Python 1.6.1 (September 2000)
 * Python 1.5.2 (April 1999)

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI and long running job

2005-12-03 Thread merry . sailor
[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Hello,
  I am using python and CGI to initiate a long running simulation (up to
  5h long) on a remote machine. The main idea is that I use a form, enter
  the parameters and a CGI scripts start the simulation using these
  parameters. The structure of the script is:
 
  1. Read paremeters
  2. Display some information
  3. Start the simulation
 
  For step 3 I use either os.system or os.popen(2). The problem is that
  the web server does not send the information of step 2 back to the
  browser, unless step 3 is completed. The browser simply waits for a
  response, without displaying anything. How can I just read the params,
  display the info I want, start the simulation and then terminate either
  the script or at least the connection to the browser without having to
  wait for the simulation to finish?
 
  I am using activestate python 2.4, Apache and WinXP.
 
  Thanks a lot for your help.

 Maybe you could use 'os.spawn' variants with the P_NOWAIT parameter...
 (not sure of the syntax here, it's in the doc)
 Good luck!

Thanks for answering. I tried that but it didn't work. Nothing is sent
back to the browser until the spawned process has ended. This is true
even if the spawn command (or any other similar command) is the last
statement of the script.

Is there some way to send back to the browser whatever info I need,
close the connection and then continue executing the commands I need,
using the same script?

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


Re: advice : how do you iterate with an acc ?

2005-12-03 Thread Scott David Daniels
Jeffrey Schwab wrote:
 [EMAIL PROTECTED] wrote:
 hello,

  i often encounter something like:

 acc = []# accumulator ;)
 for line in fileinput.input():
 if condition(line):
 if acc:#1
 doSomething(acc)#1
 acc = []
 else:
 acc.append(line)
 if acc:#2
 doSomething(acc)#2
 
 Could you add a sentry to the end of your input?  E.g.:
 for line in fileinput.input() + line_that_matches_condition:
 This way, you wouldn't need a separate check at the end.

Check itertools for a good way to do this:

 import itertools
 SENTRY = 'something for which condition(SENTRY) is True'

 f = open(filename)
 try:
 for line in itertools.chain(f, [SENTRY]):
 if condition(line):
 if acc:
 doSomething(acc)
 acc = []
 else:
 acc.append(line)
 assert acc == []
 finally:
 f.close()


--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


urllib on windows machines

2005-12-03 Thread william
I've got a strange problem on windows (not very familiar with that OS).

I can ping a host, but cannot get it via urllib (see here under).
I can even telnet the host on port 80.

Thus network seems good, but not for python ;-(.

Does any windows specialist can guide me (a poor linux user) to get
Network functionalitiies with python on windows ?

I'm runnning on Windows XP (sorry to not give more, I don't know the
equivalent of uname).
I'm using standard (msi) python-2.4.2

Thanks.



test.py contains the following lines:

import urllib
g=urllib.urlopen('http://www.google.com')



C:\Temppython test.py
Traceback (most recent call last):
  File test.py, line 2, in ?
g=urllib.urlopen('http://www.google.com')
  File c:\william\tools\python24\lib\urllib.py, line 77, in urlopen
return opener.open(url)
  File c:\william\tools\python24\lib\urllib.py, line 185, in open
return getattr(self, name)(url)
  File c:\william\tools\python24\lib\urllib.py, line 308, in
open_http
h.endheaders()
  File c:\william\tools\python24\lib\httplib.py, line 795, in
endheaders
self._send_output()
  File c:\william\tools\python24\lib\httplib.py, line 676, in
_send_output
self.send(msg)
  File c:\william\tools\python24\lib\httplib.py, line 643, in send
self.connect()
  File c:\william\tools\python24\lib\httplib.py, line 627, in connect
raise socket.error, msg
IOError: [Errno socket error] (10053, 'Software caused connection
abort')

C:\Tempping www.google.com

Pinging www.l.google.com [66.249.93.104] with 32 bytes of data:

Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=23ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246

Ping statistics for 66.249.93.104:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 22ms, Maximum = 23ms, Average = 22ms

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


Re: Python Unicode decimal interpretation

2005-12-03 Thread Scott David Daniels
Martin v. Löwis wrote:
 Scott David Daniels wrote:
 In reading over the source for CPython's PyUnicode_EncodeDecimal,
 I see a dance to handle characters which are neither dec-equiv nor
 in Latin-1.  Does anyone know about the intent of such a conversion?
 
 To support this:
 
   int(u\N{DEVANAGARI DIGIT SEVEN})
 7
OK, That much I have handled.  I am fiddling with direct-to-number
conversions and wondering about cases like
 int(u\N{DEVANAGARI DIGIT SEVEN} + XXX
+ u\N{DEVANAGARI DIGIT SEVEN})

Where XXX does not pass the digit test, but must either:
 (A) be dropped, giving a result of 77
or  (B) get translated (e.g. to u'234') giving 72347
or  (C) get translated (to u'2' + YYY + u'4') where YYY will
 require further handling ...

I don't really understand how the ignore or something_else
cases get caused by python source [where they come from].  Are they
only there for C-program access?

 In the ignore case, no output is produced at all, for the unencodable
 character; this is the same way that '?' would be treated (it is
 also unencodable).
If I understand you correctly -- I can consider the digit stream to stop
as soon as I hit a non-digit (except for handling bases 11-36).

 In the something_else case, a user-defined exception handler could
 treat the error in any way it liked, e.g. encoding all letters
 u'A' to digit '0'. This might be different from the way this error
 handler would treat '?'.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


running a c program from a python script

2005-12-03 Thread johnclare
Help - I'm (very) new to python.  I want to run run a c executable from
a python script - how do I do this?

Many thanks for your help,
j

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


Re: urllib on windows machines

2005-12-03 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 I've got a strange problem on windows (not very familiar with that OS).
 I can ping a host, but cannot get it via urllib (see here under).
  Thus network seems good, but not for python ;-(.
 
 Does any windows specialist can guide me (a poor linux user) to get
 Network functionalitiies with python on windows ?
 
 I'm runnning on Windows XP (sorry to not give more, I don't know the
 equivalent of uname).

This part I can help you with:
  import platform
  platform.platform()
 'Windows-2000-5.0.2195-SP4'  # in my case
  platform.architecture()
 ('32bit', 'WindowsPE')
  platform.python_version()
 '2.4.2'
  platform.python_compiler()
 'MSC v.1310 32 bit (Intel)'
  platform.python_build()
 (67, 'Sep 28 2005 12:41:11')

 test.py contains the following lines:
 
 import urllib
 g=urllib.urlopen('http://www.google.com')
 
  ...

I'm on a Win2K 2.4.2 system, and Idle let's me do:
  import urllib
  g = urllib.urlopen('http://www.google.com')
  g.read(12)
 'htmlhead'

So off-hand, I'd suspect some firewall thingie is getting in the way.
Can you bless \Python24\python.exe and \Python24\pythonw.exe as
applications allowed to do net traffic?

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running a c program from a python script

2005-12-03 Thread Scott David Daniels
johnclare wrote:
 Help - I'm (very) new to python.  I want to run run a c executable from
 a python script - how do I do this?
 
 Many thanks for your help,
 j
 
generally:
 import os
 os.execl(program_location)
Look in os, Process management for further details.  The next time
you ask, you really should mention your OS and Python versions; the
fiddley details differ.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running a c program from a python script

2005-12-03 Thread johnclare
Great stuff, thanks, it works.

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


Re: CGI and long running job

2005-12-03 Thread Mardy
Le die Fri, 02 Dec 2005 20:35:52 -0800, merry.sailor ha scribite:
 For step 3 I use either os.system or os.popen(2). The problem is that
 the web server does not send the information of step 2 back to the
 browser, unless step 3 is completed. The browser simply waits for a
 response, without displaying anything. How can I just read the params,
 display the info I want, start the simulation and then terminate either
 the script or at least the connection to the browser without having to
 wait for the simulation to finish?

Sounds weird. What if you connect to the webserver via telnet? Do you get
any output?
you could try to call sys.stdout.flush() in the CGI, but I never had the
need to do that.
Maybe it's just a browser's problem?


-- 
Saluti,
Mardy
http://interlingua.altervista.org

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


Re: Eclipse best/good or bad IDE for Python?

2005-12-03 Thread BartlebyScrivener
if it is the *best* IDE for Python. 

Nobody can answer this for you. Just try them all. The two I like that
I don't see mentioned in this thread are PythonCard (which is free) and
WingWare (which costs $30.00 but you can try for free.)

bs

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


SCPocketGrades released

2005-12-03 Thread Philippe C. Martin
Dear all,

I am very pleased to announce the release of SCPocketGrades V 0.1.

SCPocketGrades is a GPL U3 smart drive-based grade book application.

SCPocketGrades is coded in Python, wxPython, and C.

SCPocketGrades' main features are:

 - (U3): no PC installation + data saved on smart drive (no more grading at 
school during the week-ends)
 - Multiple class management
 - csv import/export
 - share class data (ex: with substitute teacher)
 - Curve support
 - Category/weight support
 - Reporting (filter by date/category/assignment/student/class):
   Data plotting/export
   Html formatted report mailing (configure your email settings from the 
application)
 - Missing/excused assignment support




SCPocketGrades may be found on www.snakecard.com, download section. 


For supported OS list, please see www.u3.com

Please note that SCPocketGrades has not yet obtained the U3 logo

For those interested in looking at the source code, rename
SCPocketGrades.u3p to SCPocketGrades.zip and unzip. Screenshots also
available.

(Commercial support/customization available)


Regards,

Philippe

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


Re: SCPocketGrades released

2005-12-03 Thread Philippe C. Martin
oops: www.snakecard.com/src

On Sat, 03 Dec 2005 12:26:52 -0600, Philippe C. Martin wrote:

 Dear all,
 
 I am very pleased to announce the release of SCPocketGrades V 0.1.
 
 SCPocketGrades is a GPL U3 smart drive-based grade book application.
 
 SCPocketGrades is coded in Python, wxPython, and C.
 
 SCPocketGrades' main features are:
 
  - (U3): no PC installation + data saved on smart drive (no more grading at 
 school during the week-ends)
  - Multiple class management
  - csv import/export
  - share class data (ex: with substitute teacher)
  - Curve support
  - Category/weight support
  - Reporting (filter by date/category/assignment/student/class):
Data plotting/export
Html formatted report mailing (configure your email settings from the 
 application)
  - Missing/excused assignment support
 
 
 
 
 SCPocketGrades may be found on www.snakecard.com, download section. 
 
 
 For supported OS list, please see www.u3.com
 
 Please note that SCPocketGrades has not yet obtained the U3 logo
 
 For those interested in looking at the source code, rename
 SCPocketGrades.u3p to SCPocketGrades.zip and unzip. Screenshots also
 available.
 
 (Commercial support/customization available)
 
 
 Regards,
 
 Philippe

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


Re: Python Unicode decimal interpretation

2005-12-03 Thread Martin v. Löwis
Scott David Daniels wrote:
   int(u\N{DEVANAGARI DIGIT SEVEN})
 7
 
 OK, That much I have handled.  I am fiddling with direct-to-number
 conversions and wondering about cases like
 int(u\N{DEVANAGARI DIGIT SEVEN} + XXX
+ u\N{DEVANAGARI DIGIT SEVEN})

int() passes NULL as error mode, equalling strict. So if you get an
unencodable character, you get the UnicodeError.

 I don't really understand how the ignore or something_else
 cases get caused by python source [where they come from].  Are they
 only there for C-program access?

Neither, nor. This code is dead.

 In the ignore case, no output is produced at all, for the unencodable
 character; this is the same way that '?' would be treated (it is
 also unencodable).
 
 If I understand you correctly -- I can consider the digit stream to stop
 as soon as I hit a non-digit (except for handling bases 11-36).

No. In ignore mode, a codec doesn't stop at the unencodable character.
Instead, it skips it, continuing with the next character.

I mistakenly said that this would happen to '?' (question mark) also;
this is incorrect: PyUnicode_EncodeDecimal copies all Latin-1 characters
to the output, latin-1-encoded. So '?' would appear in the output,
even in ignore mode.

Handling of bases is not done in the function at all. Instead, the
callers of PyUnicode_EncodeDecimal will deal with number formats
(base, prefix, exponent syntax, etc.) They will assume ASCII
bytes.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cheapest pocket device to code python on

2005-12-03 Thread adDoc's networker Phil
. I could actually touch-type on the psion (a genuine [/]pocket computer!)
but I was looking forward to eventually writing a key mapper
(new key layouts are always an aggravation)
. my plans were snipped in the bud however,
because I got cheap and tried to sneak around the warranty with a universal ac adaptor;
I didn't check the voltage myself with a meter,
and found out the hard way that it was putting out twice the expected voltage
. apparently a lot of other people were making mistakes like that,
because shortly after psion arrived from the uk,
they dropped customer service for the usa
-- except the corporate acct's, 
where they could deal with professional IT staff who didn't need their nose wiped !
On 11/26/05, Ten [EMAIL PROTECTED] wrote:
I use an old epocpython on a Psion Revo Plus for jotting down python conceptsand testing out ideas, and I wouldn't be without it - especially because theRevo keyboard is usable in a way touchscreens aren't for me.
It's not the most extensive python installation, and it won't stand muchearthshifting (it doesn't include some modules, like tkinter) but it's a hellof a lot of portable python considering the fact you can pick one up for
around 10 to 20 squids on ebay.Better keyboard than a pda, portable python for next to nothing.--http://mail.python.org/mailman/listinfo/python-list
-- American Dream Documentshttp://www.geocities.com/amerdreamdocs/home/(real opportunity starts with real documentation)
-- 
http://mail.python.org/mailman/listinfo/python-list

Command Line drive Tk window

2005-12-03 Thread annagel
I have been working to build a media toolkit that uses pygame to modify
image and sound data for the user.  I have all of this working fine.
The one thing I am working on now is adding a pop-up view for the image
data as well as some pop-ups for file selection and color picking.  I
am having problems with the first part of this which I think will carry
through to the file/color pickers but all of that is secondary anyway
so not too big a deal.

Basically the module is set up so after importing it must be
initialized.  This initializes a bunch of pygame stuff and also starts
a thread to watch for user events on its windows.  I just create a Pk
instance and withdraw it (this is ok because this thread is run as
daemon so the program won't be stalled from exiting by a window they
can't see to close).  Then when the user wants to view one of their
images in a window they call a function in the object which converts
the image to a PIL image and imports it to a Toplevel Pk window.  The
problem is that this window does not become visible.  I did some
investigation and found that if I did not withdraw my root window I
could get the Toplevel to show by clicking the root window.  What I
think what is actually going on here is that the Tk mainloop is only
looking for user events generated by the gui itself so when I try to do
something from the comand line the mainloop is not looking for the
event.

Does anyone know of a way I can overcome this problem.  I have tried
creating a second loop that just keeps hitting the main window by
calling update, this does not work the update stalls until I click with
window just like creation of the toplevel window.  Finally I have also
tried cyclicly adding an after_idle call to the window so it will keep
calling some function when it goes to idle figuing I could keep the
main loop alive perhaps in this way.  This prevented the main window
from apearing at all and so this is not a good option.

Any thought would be apreciated,
Andrew

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-03 Thread Tom Anderson
On Fri, 2 Dec 2005, [EMAIL PROTECTED] wrote:

 Dave Hansen wrote:

 TAB characters are evil.  They should be banned from Python source 
 code. The interpreter should stop translation of code and throw an 
 exception when one is encountered.  Seriously.  At least, I'm serious 
 when I say that.  I've never seen TAB characters solve more problems 
 than they cause in any application.

 But I suspect I'm a lone voice crying in the wilderness.  Regards,

 You're not alone.

 I still don't get why there is still people using real tabs as
 indentation.

I use real tabs. To me, it seems perfectly simple - i want the line to be 
indented a level, so i use a tab. That's what tabs are for. And i've 
never, ever come across any problem with using tabs.

Spaces, on the otherhand, can be annoying: using spaces means that the 
author's personal preference about how wide a tab should be gets embedded 
in the code, so if that's different to mine, i end up having to look at 
weird code. Navigating and editing the code with arrow-keys under a 
primitive editor, which one is sometimes forced to do, is also slower and 
more error-prone.

So, could someone explain what's so evil about tabs?

tom

-- 
Space Travel is Another Word for Love!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: urllib on windows machines

2005-12-03 Thread william
Thanks Scott


 This part I can help you with:
   import platform
   platform.platform()
  'Windows-2000-5.0.2195-SP4'  # in my case
   platform.architecture()
  ('32bit', 'WindowsPE')
   platform.python_version()
  '2.4.2'
   platform.python_compiler()
  'MSC v.1310 32 bit (Intel)'
   platform.python_build()
  (67, 'Sep 28 2005 12:41:11')


 import platform
 platform.platform()
'Windows-XP-5.1.2600'
 platform.architecture()
('32bit', 'WindowsPE')
 platform.python_version()
'2.4.2'
 platform.python_compiler()
'MSC v.1310 32 bit (Intel)'
 platform.python_build()
(67, 'Sep 28 2005 12:41:11')


 So off-hand, I'd suspect some firewall thingie is getting in the way.
 Can you bless \Python24\python.exe and \Python24\pythonw.exe as
 applications allowed to do net traffic?


Bingo!
That's the problem: Blocked outgoing TCP - Source Local: (1898)
Destination: 67.18.1.164: http(80)

But why the telnet www.google.com 80 is wroking ?
Why Firefox is running ?

Thanks.



William

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


Re: urllib on windows machines

2005-12-03 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 ...
[I said]
 So off-hand, I'd suspect some firewall thingie is getting in the way.
 Can you bless \Python24\python.exe and \Python24\pythonw.exe as
 applications allowed to do net traffic?
 
 Bingo!
 That's the problem: Blocked outgoing TCP - Source Local: (1898)
 Destination: 67.18.1.164: http(80)
 
 But why the telnet www.google.com 80 is wroking ?
 Why Firefox is running ?

Because (and I'm guessing here), telnet, ftp, firefox, ... are all
web-specific, and they are not regarded as possible monsters if they
try to connect to the web.  I'd like the chance to deny all programs
that I don't expect to connect out the chance to do so, but there has
got to be a way to turn it off.  Maybe there are some adjustments to
the program that emitted the Blocked outgoing TCP - ... message.

-- 
-Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-03 Thread Scott David Daniels
Tom Anderson wrote:
 On Fri, 2 Dec 2005, [EMAIL PROTECTED] wrote:
 
 Dave Hansen wrote:

 TAB characters are evil.  They should be banned from Python source 
 code. The interpreter should stop translation of code and throw an 
 exception when one is encountered.  Seriously.  At least, I'm serious 
 when I say that.  I've never seen TAB characters solve more problems 
 than they cause in any application.

 So, could someone explain what's so evil about tabs?

They appear in different positions on different terminals (older hard-
copy), do different things on different OS's, and in general do not
behave nicely.  On many (but not all) systems, they advance to the next
column that is a multiple of 8, but not all, and people (and editors)
use them freely to get to those positions, not understanding that they
are not necessarily going to the same position.  The fact that they
provide an ambiguous display is enough to make them evil.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Equivalent to Text::Autoformat

2005-12-03 Thread BartlebyScrivener
I'm new to both Perl  Python.

Is there a Python module or script somewhere comparable to the useful
Perl module - Text::Autoformat?

Thanks,

BS

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-03 Thread D H
Scott David Daniels wrote:
 Tom Anderson wrote:
 So, could someone explain what's so evil about tabs?
 
 
 They appear in different positions on different terminals (older hard-
 copy), do different things on different OS's, and in general do not
 behave nicely.  On many (but not all) systems, they advance to the next
 column that is a multiple of 8, but not all, and people (and editors)
 use them freely to get to those positions, not understanding that they
 are not necessarily going to the same position.  The fact that they
 provide an ambiguous display is enough to make them evil.

How is that a problem that some editors use 8 columns for tabs and 
others use less?  So what?
A bigger problem I see is people using only 2 or 3 spaces for indenting. 
  That makes large amounts of code much less readable.  And of course it 
is a problem if you mix tabs and spaces at the beginning of the same line.
Tabs are easier to type (one keystroke each) and lead to visually better 
results (greater indentation unless you like hitting 8 spaces for each 
indent level).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI and long running job

2005-12-03 Thread merry . sailor
Hello Mardy,
thanks a lot for your help. I found the problem. Your suggestion made
me look into some things I haven't thought before :-). I don't know if
it is a browser/server/mine fault. The problem was that I was sending
text/plain and a txt file. I soon as I started sending back to the
browser text/html and an html file, I started getting the things I
wanted on screen, but the browser still waited for the script to
terminate, which resulted in a timeout. After I also closed stdout,
everything worked fine. The strange thing is that I tried closing
stdout with the plain text before, but it didn't work.

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-03 Thread Sybren Stuvel
D H enlightened us with:
 How is that a problem that some editors use 8 columns for tabs and
 others use less?  So what?

I don't care either. I always use tabs, and my code is always
readable. Some people suggest one indents with four spaces, and
replaces eight spaces of indenting with a tab. Now _that_ is
irritating, since my editor's tab size is set to 4.

 Tabs are easier to type (one keystroke each)

That depends on your editor. Mine (vim) can be instructed to insert
the appropriate amount of spaces on a tab, and remove them on a
backspace.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: advice : how do you iterate with an acc ?

2005-12-03 Thread Bengt Richter
On 3 Dec 2005 03:28:19 -0800, [EMAIL PROTECTED] wrote:


Bengt Richter wrote:
 On 2 Dec 2005 18:34:12 -0800, [EMAIL PROTECTED] wrote:

 
 Bengt Richter wrote:
  It looks to me like itertools.groupby could get you close to what you 
  want,
  e.g., (untested)
 Ah, groupby. The generic string.split() equivalent. But the doc said
 the input needs to be sorted.
 

   seq = [3,1,4,'t',0,3,4,2,'t',3,1,4]
   import itertools
   def condition(item): return item=='t'
  ...
   def dosomething(it): return 'doing something with %r'%list(it)
  ...
   for condresult, acciter in itertools.groupby(seq, condition):
  ... if not condresult:
  ... dosomething(acciter)
  ...
  'doing something with [3, 1, 4]'
  'doing something with [0, 3, 4, 2]'
  'doing something with [3, 1, 4]'

 I think the input only needs to be sorted if you a trying to group sorted 
 subsequences of the input.
 I.e., you can't get them extracted together unless the condition is 
 satisfied for a contiguous group, which
 only happens if the input is sorted. But AFAIK the grouping logic just scans 
 and applies key condition
 and returns iterators for the subsequences that yield the same key function 
 result, along with that result.
 So it's a general subsequence extractor. You just have to supply the key 
 function to make the condition value
 change when a group ends and a new one begins. And the value can be 
 arbitrary, or just toggle beween two values, e.g.

   for condresult, acciter in itertools.groupby(range(20), lambda x:x%3==0 
 or x==5):
  ... print '%6s: %r'%(condresult, list(acciter))
  ...
True: [0]
   False: [1, 2]
True: [3]
   False: [4]
True: [5, 6]
   False: [7, 8]
True: [9]
   False: [10, 11]
True: [12]
   False: [13, 14]
True: [15]
   False: [16, 17]
True: [18]
   False: [19]

 or a condresult that stays the same in groups, but every group result is 
 different:

   for condresult, acciter in itertools.groupby(range(20), lambda x:x//3):
  ... print '%6s: %r'%(condresult, list(acciter))
  ...
   0: [0, 1, 2]
   1: [3, 4, 5]
   2: [6, 7, 8]
   3: [9, 10, 11]
   4: [12, 13, 14]
   5: [15, 16, 17]
   6: [18, 19]

Thanks. So it basically has an internal state storing the last
condition result and if it flips(different), a new group starts.

So it appears. But note that flips(different) seems to be based on ==,
and default key function is just passthrough like lambda x:x, so e.g. integers
and floats will group together if their values are equal.
E.g., to elucidate further,

Default key function:
  from itertools import groupby
  for k,g in groupby([0, 0.0, 0j, [], (), None, 1, 1.0, 1j]):
 ... print k, list(g)
 ...
 0 [0, 0.0, 0j]
 [] [[]]
 () [()]
 None [None]
 1 [1, 1.0]
 1j [1j]

Group by bool value:
  for k,g in groupby([0, 0.0, 0j, [], (), None, 1, 1.0, 1j], key=bool):
 ... print k, list(g)
 ...
 False [0, 0.0, 0j, [], (), None]
 True [1, 1.0, 1j]

It's not trying to sort, so it doesn't trip on complex
  for k,g in groupby([0, 0.0, 0j, [], (), None, 1, 1.0, 1j, 2j]):
 ... print k, list(g)
 ...
 0 [0, 0.0, 0j]
 [] [[]]
 () [()]
 None [None]
 1 [1, 1.0]
 1j [1j]
 2j [2j]

But you have to watch out if you try to pre-sort stuff that includes complex 
numbers
  for k,g in groupby(sorted([0, 0.0, 0j, [], (), None, 1, 1.0, 1j, 2j])):
 ... print k, list(g)
 ...
 Traceback (most recent call last):
   File stdin, line 1, in ?
 TypeError: cannot compare complex numbers using , =, , =

And if you do sort using a key function, it doesn't mean groupy inherits that 
keyfunction for grouping
unless you specify it

  def keyfun(x):
 ... if isinstance(x, (int, long, float)): return x
 ... else: return type(x).__name__
 ...
  for k,g in groupby(sorted([0, 0.0, 0j, [], (), None, 1, 1.0, 1j, 2j], 
  key=keyfun)):
 ... print k, list(g)
 ...
 0 [0, 0.0]
 1 [1, 1.0]
 None [None]
 0j [0j]
 1j [1j]
 2j [2j]
 [] [[]]
 () [()]

Vs giving groupby the same keyfun
  for k,g in groupby(sorted([0, 0.0, 0j, [], (), None, 1, 1.0, 1j, 2j], 
  key=keyfun), keyfun):
 ... print k, list(g)
 ...
 0 [0, 0.0]
 1 [1, 1.0]
 NoneType [None]
 complex [0j, 1j, 2j]
 list [[]]
 tuple [()]


Exmple of unsorted vs sorted subgroup extraction:

  for k,g in groupby('this that other thing note order'.split(), key=lambda 
  s:s[0]):
 ... print k, list(g)
 ...
 t ['this', 'that']
 o ['other']
 t ['thing']
 n ['note']
 o ['order']

vs.

  for k,g in groupby(sorted('this that other thing note order'.split()), 
  key=lambda s:s[0]):
 ... print k, list(g)
 ...
 n ['note']
 o ['order', 'other']
 t ['that', 'thing', 'this']

Oops, that key would be less brittle as (untested) key=lambda s:s[:1], e.g., in 
case a split with args was used.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Convention for C functions success/failure

2005-12-03 Thread spam . noam
Hello,

What is the convention for writing C functions which don't return a
value, but can fail?

If I understand correctly,
1. PyArg_ParseTuple returns 0 on failure and 1 on success.
2. PySet_Add returns -1 on failure and 0 on success.

Am I correct? What should I do with new C functions that I write?

Thanks,
Noam

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


Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Brendan
There must be an easy way to do this:

For classes that contain very simple data tables, I like to do
something like this:

class Things(Object):
def __init__(self, x, y, z):
#assert that x, y, and z have the same length

But I can't figure out a _simple_ way to check the arguments have the
same length, since len(scalar) throws an exception.  The only ways
around this I've found so far are

a)  Cast each to a numeric array, and check it's dimension and shape.
This seems like far too many dependencies for a simple task:

def sLen(x):
determines the number of items in x.
Returns 1 if x is a scalar. Returns 0 if x is None

xt = numeric.array(x)
if xt == None:
return 0
elif xt.rank == 0:
return 1
else:
return xt.shape[0]

b) use a separate 'Thing' object, and make the 'Things' initializer
work only with Thing objects.  This seems like way too much structure
to me.

c) Don't bother checking the initializer, and wait until the problem
shows up later.  Maybe this is the 'dynamic' way, but it seems a little
fragile.

Is there a simpler way to check that either all arguments are scalars,
or all are lists of the same length?  Is this a poor way to structure
things?  Your advice is appreciated
   Brendan
--
Brendan Simons

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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Mike Erickson
* Brendan ([EMAIL PROTECTED]) wrote:
[...]
 Is there a simpler way to check that either all arguments are scalars,
 or all are lists of the same length?  Is this a poor way to structure
 things?  Your advice is appreciated

Disclaimer: I am new to python, so this may be a bad solution.

import types
def __init__(self,x,y,z):
isOK = False
if ( (type(x) == types.IntType) and (type(y) == types.IntType) and (type(z) 
== types.IntType) ):
isOK = True
if ( (type(x) == types.ListType) and (type(x) == types.ListType) and 
(type(x) == types.ListType) ):
if ( (len(x) == len(y)) and (len(x) == len(z)) ):
isOK = True

HTH,

mike

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


distutils problem windows xp python 2.4.2

2005-12-03 Thread [EMAIL PROTECTED]
Hello I tried to combine c++ and python together.
So I follow from this website:
http://kortis.to/radix/python_ext/

I have this code:
# prmodule.c
static PyObject *pr_isprime(PyObject *self, PyObject *args){
int n, input;

if (!PyArg_ParseTuple(args, i, input))
  return NULL;

if (input  1) {
return Py_BuildValue(i, 0);
}

n = input - 1;

while (n  1){
if (input%n == 0) return Py_BuildValue(i, 0);;
n--;
}

return Py_BuildValue(i, 1);
}

static PyMethodDef PrMethods[] = {
{isprime, pr_isprime, METH_VARARGS, Check if prime.},
{NULL, NULL, 0, NULL}
};

void initpr(void){
(void) Py_InitModule(pr, PrMethods);
}



and my setup.py file:
from distutils.core import setup, Extension
module = Extension('pr', sources = ['prmodule.c'])
setup(name = 'Pr test', version = '1.0', ext_modules = [module])


If I run setup build
I've got the following error message
running build
running build_ext
error: The .NET Framework SDK needs to be installed before building
extensions for Python.

I use visual Studio 2005.

Thanks,
pujo

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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Alex Martelli
Brendan [EMAIL PROTECTED] wrote:
   ...
 def sLen(x):
 determines the number of items in x.
 Returns 1 if x is a scalar. Returns 0 if x is None
 
 xt = numeric.array(x)
 if xt == None:
 return 0
 elif xt.rank == 0:
 return 1
 else:
 return xt.shape[0]

Simpler:

def sLen(x):
if x is None: return 0
try: return len(x)
except TypeError: return 1

Depending on how you define a scalar, of course; in most applications,
a string is to be treated as a scalar, yet it responds to len(...), so
you'd have to specialcase it.


Alex


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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Sam Pointon
It depends what you mean by 'scalar'. If you mean in the Perlish sense
(ie, numbers, strings and references), then that's really the only way
to do it in Python - there's no such thing as 'scalar context' or
anything - a list is an object just as much as a number is.

So, assuming you want a Things object to break if either a) all three
arguments aren't sequences of the same length, or b) all three
arguments aren't a number (or string, or whatever), this should work:

#Not tested.
class Things(object):
def __init__(self, x, y, z):
try:
if not (len(x) == len(y) and len(y) == len(z)):
raise ValueError('Things don't match up.')
except TypeError:
#one of x, y or z doesn't do __len__
#check if they're all ints, then.
if not (isinstance(x, int) and isinstance(y, int) and
isinstance(z, int)):
raise ValuError('Things don't match up')
#do stuff.

Personally, I find nothing wrong with having a separate Thing object
that can do validation for itself, and I think it's a pleasantly object
oriented solution

I'm also wondering why something like this could accept something other
than sequences if it depends on their length. If you just want to treat
non-sequences as lists with one value, then something like this is more
appropriate, and might lead to less redundancy in other places:

def listify(obj):
try:
return list(obj)
except TypeError
return [obj]

class Things(object):
def __init__(self, *args):
x, y, z = [listify(arg) for arg in args]
if not (len(x) == len(y) and len(y) == len(z)):
raise ValueError('Things don't match up')

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


Re: distutils problem windows xp python 2.4.2

2005-12-03 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
 Hello I tried to combine c++ and python together.
 So I follow from this website:
 http://kortis.to/radix/python_ext/
  
 and my setup.py file:
 from distutils.core import setup, Extension
 module = Extension('pr', sources = ['prmodule.c'])
 setup(name = 'Pr test', version = '1.0', ext_modules = [module])
 
 
 If I run setup build
 I've got the following error message
 running build
 running build_ext
 error: The .NET Framework SDK needs to be installed before building
 extensions for Python.
 
 I use visual Studio 2005.
 
 Thanks,
 pujo
 
You might take a look at:

http://groups.google.com/group/comp.lang.python/msg/2341e3ac80ae5052?dmode=source

it provides code to change your setup code to:
 from distutils.core import setup, Extension
 module = Extension('pr', sources = ['prmodule.c'])

for attempts in range(2):
 try:
 setup(name='Pr test',
   version='1.0',
   ext_modules=[module])
 except SystemExit, e: pass # Failure. Patch and try again
 else: break # Successful run, no need to retry.

 print '*** Apparently a failure:', e.args[0]
 print '*** Patching and trying again'
 import patch_msvccompiler

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI module does not parse data

2005-12-03 Thread Tim Roberts
amfr [EMAIL PROTECTED] wrote:

import cgi
form = cgi.FieldStorage()
print form[test]
print test

I would only be able to see test, not hello world
I am sure its not my browser

Did you mean:

  print form[test].value
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CGI and long running job

2005-12-03 Thread Tim Roberts
[EMAIL PROTECTED] wrote:

Hello,
I am using python and CGI to initiate a long running simulation (up to
5h long) on a remote machine. The main idea is that I use a form, enter
the parameters and a CGI scripts start the simulation using these
parameters. The structure of the script is:

1. Read paremeters
2. Display some information
3. Start the simulation

For step 3 I use either os.system or os.popen(2). The problem is that
the web server does not send the information of step 2 back to the
browser, unless step 3 is completed. The browser simply waits for a
response, without displaying anything. How can I just read the params,
display the info I want, start the simulation and then terminate either
the script or at least the connection to the browser without having to
wait for the simulation to finish?

You need to close stdout, which closes the socket and allows the browser to
finish.  This is what I use:

  # We flush stdout, fork, then close stdout.  This closes the HTTP socket,
  # allowing the browser to continue while we munge with sendmail.

  sys.stdout.flush()
  if os.fork(): return
  fw = open('/dev/null','w')
  os.dup2(fw.fileno(),1)
  os.dup2(fw.fileno(),2)
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Function to retrieve running script

2005-12-03 Thread Harlin Seritt
Is there a function that allows one to get the name of the same script
running returned as a string?

Thanks,

Harlin Seritt

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


Scientific Notation

2005-12-03 Thread Dustan
How can I get a number into scientific notation? I have a preference
for the format '1 E 50' (as an example), but if it's well known, it
works.

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


Re: Function to retrieve running script

2005-12-03 Thread Alex Martelli
Harlin Seritt [EMAIL PROTECTED] wrote:

 Is there a function that allows one to get the name of the same script
 running returned as a string?

Something like:

import sys
def f():
  return sys.modules['__main__'].__file__

might help.


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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Alex Martelli
Sam Pointon [EMAIL PROTECTED] wrote:
   ...
 So, assuming you want a Things object to break if either a) all three
 arguments aren't sequences of the same length, or b) all three
 arguments aren't a number (or string, or whatever), this should work:
 
 #Not tested.
 class Things(object):
 def __init__(self, x, y, z):
 try:
 if not (len(x) == len(y) and len(y) == len(z)):
 raise ValueError('Things don't match up.')

Careful though: this does NOT treat a string as a scalar, as per your
parenthetical note, but rather as a sequence, since it does respond
correctly to len(...).  You may need to specialcase with checks on
something like isinstance(x,basestring) if you want to treat strings as
scalars.


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


Re: Scientific Notation

2005-12-03 Thread Alex Martelli
Dustan [EMAIL PROTECTED] wrote:

 How can I get a number into scientific notation? I have a preference
 for the format '1 E 50' (as an example), but if it's well known, it
 works.

You mean something like:

 print '%e' % (1e50)
1.00e+50

...?


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


Re: Scientific Notation

2005-12-03 Thread Dustan
No, I mean given a big number, such as
1000, convert it into
scientific notation.

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


Re: Scientific Notation

2005-12-03 Thread Roy Smith
In article [EMAIL PROTECTED],
 Dustan [EMAIL PROTECTED] wrote:

 1000

 print %e % 1000
1.00e+51
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Scientific Notation

2005-12-03 Thread Alex Martelli
Roy Smith [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  Dustan [EMAIL PROTECTED] wrote:
 
  1000
 
  print %e % 1000
 1.00e+51

Exactly: the %e builds a ``scientific-notation string from whatever
number you're formatting that way (big or small).  You can also use %g
if what you want is fixed-point notation within a certain range and
scientific notations only for numbers OUTSIDE that range, as in:

 print '%g' % 10**5
10
 print '%g' % 10**50
1e+50


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


Re: Scientific Notation

2005-12-03 Thread Jorge Godoy
Dustan [EMAIL PROTECTED] writes:

 No, I mean given a big number, such as
 1000, convert it into
 scientific notation.

It's the same.

 print %e % 1000
1.00e+51


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread [EMAIL PROTECTED]
I am trying to run an exe within a python script, but I'm having
trouble with spaces in the directory name.

The following example will display the usage statement of the program,
so I know that the space in the path to the exe is being handled
correctly and that the program was executed.

CMD= r'C:\program files\some directory\engine\theexe.exe'
os.system(CMD)

But the required argument for the exe require a path to a file to be
specified.  When I try to run the following, os.system(CMD2)
CMD2= r'C:\program files\some directory\engine\theexe.exe C:\program
files\some directory\engine\file.txt'

I get this error:
Unable to open file C:\Program

So, it looks to me like the space in the path for the argument is
causing it to fail.  Does anyone have any suggestions that could help
me out?
Thanks,
Steve

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


regexp non-greedy matching bug?

2005-12-03 Thread John Hazen
I want to match one or two instances of a pattern in a string.

According to the docs for the 're' module 
( http://python.org/doc/current/lib/re-syntax.html ) the '?' qualifier
is greedy by default, and adding a '?' after a qualifier makes it
non-greedy.

 The *, +, and ? qualifiers are all greedy...
 Adding ? after the qualifier makes it perform the match in
 non-greedy or minimal fashion...

In the following example, though my re is intended to allow for 1 or 2
instinces of 'foo', there are 2 in the string I'm matching.  So, I would
expect group(1) and group(3) to both be populated.  (When I remove the
conditional match on the 2nd foo, the grouping is as I expect.)

$ python2.4
Python 2.4.1 (#2, Mar 31 2005, 00:05:10) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type help, copyright, credits or license for more information.
 import re
 foofoo = re.compile(r'^(foo)(.*?)(foo)?(.*?)$')
 foofoo.match(s).group(0)
'foobarbazfoobar'
 foofoo.match(s).group(1)
'foo'
 foofoo.match(s).group(2)
''
 foofoo.match(s).group(3)
 foofoo.match(s).group(4)
'barbazfoobar'
 foofoo = re.compile(r'^(foo)(.*?)(foo)(.*?)$')
 foofoo.match(s).group(0)
'foobarbazfoobar'
 foofoo.match(s).group(1)
'foo'
 foofoo.match(s).group(2)
'barbaz'
 foofoo.match(s).group(3)
'foo'
 foofoo.match(s).group(4)
'bar'



So, is this a bug, or just a problem with my understanding?  If it's my
brain that's broken, what's the proper way to do this with regexps?

And, if the above is expected behavior, should I submit a doc bug?  It's
clear that the ? qualifier (applied to the second foo group) is _not_
greedy in this situation.

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


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread jepler
This comes up from time to time.  The brain damage is all Windows', not
Python's.  Here's one thread which seems to suggest a bizarre doubling
of the initial quote of the commandline.

http://groups.google.com/group/comp.lang.python/browse_frm/thread/89d94656ea393d5b/ef40a65017848671


pgp1T5KPY01oo.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread Vijay L
I don't have any problems with spaces in the folders.

just for debugging, you could probably try os.system(CMD.replace(\\, /)

On 3 Dec 2005 19:16:10 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I am trying to run an exe within a python script, but I'm having
 trouble with spaces in the directory name.

 The following example will display the usage statement of the program,
 so I know that the space in the path to the exe is being handled
 correctly and that the program was executed.

 CMD= r'C:\program files\some directory\engine\theexe.exe'
 os.system(CMD)

 But the required argument for the exe require a path to a file to be
 specified.  When I try to run the following, os.system(CMD2)
 CMD2= r'C:\program files\some directory\engine\theexe.exe C:\program
 files\some directory\engine\file.txt'

 I get this error:
 Unable to open file C:\Program

 So, it looks to me like the space in the path for the argument is
 causing it to fail.  Does anyone have any suggestions that could help
 me out?
 Thanks,
 Steve

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

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


Re: regexp non-greedy matching bug?

2005-12-03 Thread Sam Pointon
My understanding of .*? and its ilk is that they will match as little
as is possible for the rest of the pattern to match, like .* will match
as much as possible. In the first instance, the first (.*?) did not
have to match anything, because all of the rest of the pattern can be
matched 0 or more times. I think that such a situation (non-greedy
operator followed by operators that match 0 or more times) will never
match. However, in the second instance, it has to match something later
on in the string, so it will capture something.

I believe that this is an operator precedence problem (greedy ? losing
to .*?), but is to be expected. So, if this is the case, by all means
it should be added in a note to the docs.

However, I am not a regular expression expert, so my analysis of the
situation may be well off the mark.

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


SOAPpy SOAP and/or WSDL Question

2005-12-03 Thread Rodney
Hi all,

I am relatively weak in Python and I need some help with this.  I have built 
a series of SOAP client functions that ping, authenticate (password 
username), and query a SOAP server.  All works well but I cannt figure out 
on part of the download SOAP outgoing message.  I also tried WSDL and cann't 
figure it out.

The problem: there is one element called:

u'documents'

whos type is:

(u'http://www.ExchangeNetwork.net/schema/v1.0/node.xsd', 
u'ArrayOfNodeDocument')

I don't know how to make an ArrayOfNodeDocument for an element document. 
I have tried everything I can think of but I didn't have any luck.  Tried to 
send a variable with the SOAP message as the variable but the httplib method 
I used gave me an error:  gaierror: (11001, 'getaddrinfo failed').

Does anyone know how to deal with this?  I would appreciate some code if 
possible.  P.S. I don't know XML-RPC

Cheers,



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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Michael Spencer
Brendan wrote:
...
 
 class Things(Object):
 def __init__(self, x, y, z):
 #assert that x, y, and z have the same length
 
 But I can't figure out a _simple_ way to check the arguments have the
 same length, since len(scalar) throws an exception.  The only ways
 around this I've found so far are
 
...
 
 b) use a separate 'Thing' object, and make the 'Things' initializer
 work only with Thing objects.  This seems like way too much structure
 to me.
 

Yes, but depending on what you want to do with Things, it might indeed make 
sense to convert its arguments to a common sequence type, say a list.  safelist 
is barely more complex than sLen, and may simplify downstream steps.

def safelist(obj):
 Construct a list from any object.
 if obj is None:
 return []
 if isinstance(obj, (basestring, int)):
 return [obj]
 if isinstance(obj, list):
 return obj
 try:
 return list(obj)
 except TypeError:
 return [obj]

class Things(object):
 def __init__(self, *args):
 self.args = map(safelist, args)
 assert len(set(len(obj) for obj in self.args)) == 1
 def __repr__(self):
 return Things%s % self.args

   Things(0,1,2)
  Things[[0], [1], [2]]
   Things(range(2),xrange(2),(0,1))
  Things[[0, 1], [0, 1], [0, 1]]
   Things(None, 0,1)
  Traceback (most recent call last):
File input, line 1, in ?
File C:\Documents and Settings\Michael\My 
Documents\PyDev\Junk\safelist.py, line 32, in __init__
  assert len(set(len(obj) for obj in self.args)) == 1
  AssertionError


Michael



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


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
 This comes up from time to time.  The brain damage is all Windows', not
 Python's. Here's one thread which seems to suggest a bizarre doubling
 of the initial quote of the commandline.
 
 http://groups.google.com/group/comp.lang.python/browse_frm/thread/89d94656ea393d5b/ef40a65017848671

It can't all be Windows' brain damage, since typing precisely the same 
command at the prompt (at least with the example I'm using) doesn't 
require doubling the initial quote of the command line.  Or, more 
precisely, Windows is brain damaged in at least two different places 
here, and the shell is only one of them...

Also it appears the issue may be more the fact that the second argument 
*also* has quotation marks (regardless of whether it has a space in it 
or not).  It's only then (it seems) that the silly double initial 
quotation mark is required.  Either way, brain damage definitely 
describes it.

-Peter

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


newbie write to file question

2005-12-03 Thread ProvoWallis
Hi,

I'm trying to create a script that will search an SGML file for the
numbers and titles of the hierarchical elements (section level
headings) and create a dictionary with the section number as the key
and the title as the value.

I've managed to make some progress but I'd like to get some general
feedback on my progress so far plus ask a question. When I run this
script on a directory that contains multiple files even the files that
don't contain any matches generate log files and usually with the
contents of the last file that contained matches. I'm not sure what I'm
missing so I'd appreciate some advice.

Thanks,

Greg


Here's a very simplified version of my SGML:

sec-main no=1.01titlesection title 1.01
sec-sub1 no=1titletitle 1
sec-sub1 no=2titletitle 2
sec-sub2 no=atitletitle a
sec-sub2 no=btitletitle b
sec-sub3 no=ititletitle i
sec-main no=2.02titlesection title 2.02
sec-main no=3.03titlesection title 3.03
sec-sub1 no=1titletitle 1
sec-sub1 no=2titletitle 2
sec-main no=4.04titlesection title 4.04
sec-main no=5.05titlesection title 5.05

And here's what I written so far:

import os
import re

setpath = raw_input(Enter the path where the program should run: )
print

table ={}

for root, dirs, files in os.walk(setpath):
 fname = files
 for fname in files:
  inputFile = file(os.path.join(root,fname), 'r')


  while 1:
   lines = inputFile.readlines(1)
   if not lines:
break
   for line in lines:
main = re.search(r'(?i)sec-main
no=\(\d+\.\d\d)\\n?title(.*?)\n' , line)
sub_one = re.search(r'(?i)sec-sub1
no=\(\w*)\\n?title(.*?)\n' , line)
sub_two = re.search(r'(?i)sec-sub2
no=\(\w*)\\n?title(.*?)\n' , line)
sub_three = re.search(r'(?i)sec-sub3
no=\(\w*)\\n?title(.*?)\n' , line)
if main is not None:
 table[main.group(1)] = main.group(2)
 m = main.group(1)
if main is None:
 pass
if sub_one is not None:
 one = m + '[' + sub_one.group(1) + ']'
 table[one] = sub_one.group(2)
if sub_one is None:
 pass
if sub_two is not None:
 two = one + '[' + sub_two.group(1) + ']'
 table[two] = sub_two.group(2)
if sub_two is None:
 pass
if sub_three is not None:
 three = two + '[' + sub_three.group(1) + ']'
 table[three] = sub_three.group(2)
if sub_three is None:
 pass

 str_table = str(table)
 (name,ext) = os.path.splitext(fname)
 output_name = name + '.log'
 outputFile =
file(os.path.join(root,output_name), 'w')
 outputFile.write(str_table)
 outputFile.close()

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


Re: Function to retrieve running script

2005-12-03 Thread Mike Meyer
Harlin Seritt [EMAIL PROTECTED] writes:
 Is there a function that allows one to get the name of the same script
 running returned as a string?

The questions a little ambiguous, but one answer might be:

import sys
myname = sys.argv[0]

mike

-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regexp non-greedy matching bug?

2005-12-03 Thread Tim Peters
[John Hazen]
 I want to match one or two instances of a pattern in a string.

 According to the docs for the 're' module
 ( http://python.org/doc/current/lib/re-syntax.html ) the '?' qualifier
 is greedy by default, and adding a '?' after a qualifier makes it
 non-greedy.

 The *, +, and ? qualifiers are all greedy...
 Adding ? after the qualifier makes it perform the match in
 non-greedy or minimal fashion...

 In the following example, though my re is intended to allow for 1 or 2
 instinces of 'foo', there are 2 in the string I'm matching.  So, I would
 expect group(1) and group(3) to both be populated.  (When I remove the
 conditional match on the 2nd foo, the grouping is as I expect.)

 $ python2.4
 Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
 [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
 Type help, copyright, credits or license for more information.
  import re
  foofoo = re.compile(r'^(foo)(.*?)(foo)?(.*?)$')
  foofoo.match(s).group(0)
 'foobarbazfoobar'
  foofoo.match(s).group(1)
 'foo'
  foofoo.match(s).group(2)
 ''
  foofoo.match(s).group(3)
  foofoo.match(s).group(4)
 'barbazfoobar'

Your problem isn't that

(foo)?

is not greedy (it is greedy), it's that your first

(.*?)

is not greedy.  Remember that regexps also work left to right.  When
you coded your first

(.*?)

you're asking (because of the '?') the regexp engine to chew up the
fewest possible number of characters at that point such that the
_rest_ of the regexp _can_ match.  By chewing up no characters at all,
the rest of the regexp can in fact match, so that's what the engine
did -- your second

   (foo)?

is optional, telling the engine you don't require that `foo` to match.
 The engine took you at your word about that ;-)

  foofoo = re.compile(r'^(foo)(.*?)(foo)(.*?)$')

In this case your second `foo` is not optional.  The behavior wrt the first

(.*?)

really doesn't change:  the regexp engine again chews up the fewest
number of characters at that point such that the rest of the regexp
can match.  But because your second `foo` isn't optional in this case,
the engine can't get away with matching 0 characters in this case.  It
still matches the fewest number it can match there, though (consistent
with the rest of the pattern matching too).

  foofoo.match(s).group(0)
 'foobarbazfoobar'
  foofoo.match(s).group(1)
 'foo'
  foofoo.match(s).group(2)
 'barbaz'
  foofoo.match(s).group(3)
 'foo'
  foofoo.match(s).group(4)
 'bar'
 

 So, is this a bug, or just a problem with my understanding?

The behavior is what I expected ;-)

 If it's my brain that's broken, what's the proper way to do this with regexps?

Sorry, I'm unclear on (exactly) what it is you're trying to
accomplish.  Maybe what you're looking for is

^P(.*P)?.*$

?

 And, if the above is expected behavior, should I submit a doc bug?  It's
 clear that the ? qualifier (applied to the second foo group) is _not_
 greedy in this situation.

See above:  that's not only not clear, it's not true.  Consider a
related but much simpler example:

 m = re.match(r'a(b)?(b)?c', 'abc')
 m.groups()
('b', None)

Both instances of

(b)?

are greedy there, and that the second one didn't match b does not
mean that the second one is not greedy.  It _couldn't_ match without
violating that the _first_ is greedy, and the first wins because
regexps work left to right.  It may be harder to see that the same
principle is at work in your example, but it is:  your second (foo)?
couldn't match without violating that your first (.*?) asks for a
minimal match.  My

^P(.*P)?.*$

above asks the engine to match two instances of P if possible, but to
settle for one if that's all it can find.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regexp non-greedy matching bug?

2005-12-03 Thread Mike Meyer
John Hazen [EMAIL PROTECTED] writes:
 I want to match one or two instances of a pattern in a string.

Then you should be using the split() method of the match object on the
pattern in question.

 According to the docs for the 're' module 
 ( http://python.org/doc/current/lib/re-syntax.html ) the '?' qualifier
 is greedy by default, and adding a '?' after a qualifier makes it
 non-greedy.

 The *, +, and ? qualifiers are all greedy...
 Adding ? after the qualifier makes it perform the match in
 non-greedy or minimal fashion...

The thing to understand is that regular expressions are *search*
functions, that return the first parsing that matches. They search a
space of possible matches to each term in the expression. If some term
fails to match, the preceeding term goes on to its next match, and you
try again. The greedy vs. non-greedy describes the order that the
term in question tries matches. If it's greedy, it will try the
longest possible match first. If it's non-greedy, it'll try the
shortest possible match first.

 $ python2.4
 Python 2.4.1 (#2, Mar 31 2005, 00:05:10) 
 [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
 Type help, copyright, credits or license for more information.
 import re
 foofoo = re.compile(r'^(foo)(.*?)(foo)?(.*?)$')
 foofoo.match(s).group(0)
 'foobarbazfoobar'
 foofoo.match(s).group(1)
 'foo'
 foofoo.match(s).group(2)
 ''
 foofoo.match(s).group(3)
 foofoo.match(s).group(4)
 'barbazfoobar'

First, this pattern doesn't look for one or two instances of foo in
a string. It looks for a string that starts with foo and maybe has a
second foo in it as well.

Here's what it does:

^ must match the beginning of the string (BTW, you can get the same
behavior by leaving off the ^ and using search instead of match).

(foo) must match the first foo.

(.*?) is non-greedy, so it tries the shortest thing that matches, the
empty string.

(foo)? matches what's next in the string by matching 0 occurrences of
(foo).

(.*?) tries the empty string as well.

$ fails to match the end of the string, so we backtrack, and the
second (.*?) tries again, adding a character. This keeps on until the
(.*?) matches the rest of the string and the $ succeeds.

Here, the only pattern that gets retried is the last one. It keeps
adding characters until it swallows the remainder of the string. This
is exactly what's expected. You can't change this behavior with
greedy/non-greedy, as that last term will always try searching the
entire string before it fails and the preceeding (foo)? gets to try
something else.

 foofoo = re.compile(r'^(foo)(.*?)(foo)(.*?)$')
 foofoo.match(s).group(0)
 'foobarbazfoobar'
 foofoo.match(s).group(1)
 'foo'
 foofoo.match(s).group(2)
 'barbaz'
 foofoo.match(s).group(3)
 'foo'
 foofoo.match(s).group(4)
 'bar'


This time, the second (foo) keeps failing, forcing the first (.*?) to
add characters until the (foo) succeeds.

 So, is this a bug, or just a problem with my understanding?  If it's my
 brain that's broken, what's the proper way to do this with regexps?

To do what you said you want to do, you want to use the split method:

foo = re.compile('foo')
if 2 = len(foo.split(s)) = 3:
   print We had one or two 'foo's

As the founder of SPARE, I'd say the proper way to do this is with
string methods:

if 2 = len(s.split('foo')) = 3:
   print We had one or two 'foo's

Where the two split's will produce exactly the same things.

You might be able to match starts with 'foo' and has at most one
other 'foo' with lookahead patternds, but I'm not going to go into
that.  If you really need the string to start with foo, I'd just use
s.startswith('foo') to check it.

   mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Equivalent to Text::Autoformat

2005-12-03 Thread Paddy
Google is your freind.
Try searching for:
  python text wrapping

- Paddy.

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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Mike Meyer
Brendan [EMAIL PROTECTED] writes:
 There must be an easy way to do this:

Not necessarily.

 For classes that contain very simple data tables, I like to do
 something like this:

 class Things(Object):
 def __init__(self, x, y, z):
 #assert that x, y, and z have the same length

 But I can't figure out a _simple_ way to check the arguments have the
 same length, since len(scalar) throws an exception.  The only ways
 around this I've found so far are

You've gotten a number of suggestions about how to type check
things. To me, the need to type check things indicates that your API
has problems. In particular, when you're doing it on arguments, it's
indicative of trying to do the C++ thing of dispatching based on the
types of the arguments. Given duck typing, this is nearly impossible
to do correctly.

 Is there a simpler way to check that either all arguments are scalars,
 or all are lists of the same length?  Is this a poor way to structure
 things?  Your advice is appreciated

I'd say your better off providing two different interfaces to
Thing. The hard-core OO way would look like:

class Thing(object):
  def use_lists(self, x, y, z):
  assert len(x) == len(y) == len(z)
  self.x, self.y, self.z = x, y, z
  def use_scalars(self, x, y, z):
  self.x, self.y, self.z = x, y, z

This allows things that type-checking can't do. For instance, the user
can treat strings as either a scalar or sequence, their choice. If you
do the type-checking, you'll have to choose one case and stick with
it.

Also, I suspect that you can actually change do_scalars to something like
  self.x, self.y, self.z = [x], [y], [z]
and then the rest of your code will get simpler because it only has to
deal with lists.

You might also make use optional arguments, and check that you get passed
a proper subset:

class Thing(object):
  def __init__(self, x = None, y = None, z = None, scalars = None):
  if scalars:
 if x is not None or y is not None or z is not None:
raise ValueError, If present, scalars must be the only 
argument.
 self.x, self.y, self.z = scalars
  elif not (x is not None and y is not None and z is not None):
 raise ValueError, You must specify all of x, y and z
  else:
 assert len(x) == len(y) == len(z)
 self.x, self.y, self.z = x, y, z

etc.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python package installing rationale

2005-12-03 Thread Kay Schluehr
In almost any case I install a Python package via distutils some
directories in the package tree are left behind e.g. the docs,
licenses, tests etc. I wonder if there is some rationale behind this?
Should it be left to the creative freedom of the user to copy the
docs whereever she wants or is there a dedicated place for them and if
any why isn't it simple to declare it in the setup script?

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


Re: Python package installing rationale

2005-12-03 Thread Robert Kern
Kay Schluehr wrote:
 In almost any case I install a Python package via distutils some
 directories in the package tree are left behind e.g. the docs,
 licenses, tests etc. I wonder if there is some rationale behind this?
 Should it be left to the creative freedom of the user to copy the
 docs whereever she wants or is there a dedicated place for them and if
 any why isn't it simple to declare it in the setup script?

There is no such dedicated place. Or rather, there are quite a lot of
them depending on the system and the user. Debian packages have one
place for them. Fedora Core another. Windows has none at all. And so on.

distutils doesn't try to guess although sometimes authors do.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die.
  -- Richard Harter

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


Re: regexp non-greedy matching bug?

2005-12-03 Thread John Hazen
 [John Hazen]
  I want to match one or two instances of a pattern in a string.
 
   s = 'foobarbazfoobar'
   foofoo = re.compile(r'^(foo)(.*?)(foo)?(.*?)$')
   foofoo.match(s).group(1)
  'foo'
   foofoo.match(s).group(3)
   

[Tim Peters]
 Your problem isn't that
 
 (foo)?
 
 is not greedy (it is greedy), it's that your first
 
 (.*?)
 
 is not greedy.  Remember that regexps also work left to right.

Well, I had the same symptoms when that .* was greedy (it ate up the
optional foo), which is why I went to non-greedy there.

I guess my error was thinking that greedy trumped non-greedy, rather
than left trumping right.  (ie, in order for the (foo)? to be maximally
greedy, the (.*?) has to be non-maximally non-greedy :)

 Maybe what you're looking for is
 
 ^P(.*P)?.*$

Yes.  That works the way I wanted.  ( ^(foo)(.*(foo))?.*$ )

Thank you, both for the specific answer, and the general education.

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


Re: Checking length of each argument - seems like I'm fighting Python

2005-12-03 Thread Bengt Richter
On 3 Dec 2005 15:50:25 -0800, Brendan [EMAIL PROTECTED] wrote:

There must be an easy way to do this:

For classes that contain very simple data tables, I like to do
something like this:

class Things(Object):
def __init__(self, x, y, z):
#assert that x, y, and z have the same length

But I can't figure out a _simple_ way to check the arguments have the
same length, since len(scalar) throws an exception.  The only ways
around this I've found so far are

a)  Cast each to a numeric array, and check it's dimension and shape.
This seems like far too many dependencies for a simple task:

def sLen(x):
determines the number of items in x.
Returns 1 if x is a scalar. Returns 0 if x is None

xt = numeric.array(x)
if xt == None:
return 0
elif xt.rank == 0:
return 1
else:
return xt.shape[0]

b) use a separate 'Thing' object, and make the 'Things' initializer
work only with Thing objects.  This seems like way too much structure
to me.

c) Don't bother checking the initializer, and wait until the problem
shows up later.  Maybe this is the 'dynamic' way, but it seems a little
fragile.

Is there a simpler way to check that either all arguments are scalars,
or all are lists of the same length?  Is this a poor way to structure
things?  Your advice is appreciated

I'd go with c) unless you think errors that might result could be too mysterious
to diagnose or some dangerous action could result, but usually the errors won't 
be
very mysterious. If some dangerous action could result, you might well want to
impose a number of constraints, starting with checking input args, but you will
also want thorough unit tests.

Note that an assert statement gets eliminated from the generated code when 
optimization
is requested with a -O command line option, so you might want to write out the 
test and
exception raising explicitely to make sure it remains part of the code, if that 
is
what you want.

You could also define an external function to check that args conform
def __init__(self, x, y, z)
argcheck(x, y ,z) # raise exception if non-conforming

where

  scalartype = (int, long, float)
  def argcheck(*args):
 ... assert len(set([isinstance(x, scalartype) and 'S' or
 ... hasattr(x, '__len__') and len(x) for x in args]))==1
 ...
  argcheck(1, 2L, 3.0)
  argcheck([1,2], [3,4], [4,5])
  argcheck([1,2], [3,4], [4,5], 6)
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 2, in argcheck
 AssertionError
  argcheck([1,2], [3,4], [4,5,6])
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 2, in argcheck
 AssertionError
  argcheck('abc','def')
  argcheck('abc','def', 3)
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 2, in argcheck
 AssertionError

You might want to add a check on the elements of arrays, e.g. to make sure
they are all scalartypes or all complex or whatever (and so as not to
accept str elements ;-).

Note that an assert statement disappears if optimization is called for on the 
python
command line with -O, so you might want to code your own test of the condition 
and
raise an exception explicitly if appropriate.

If the assert is enough, you can of course put it directly in the __init__, 
e.g.,

def __init__(self, x, y, z)
assert len(set([isinstance(arg, scalartype) and 'S' or
hasattr(arg, '__len__') and len(arg) for arg in 
(x,y,z)]))==1
...

BTW, I'm using len(set(list_of_stuff_that_should_all_be_equal))==1 to test that 
they are equal,
since if not, there would be more than one element in the set. So there should 
either be
a bunch of 'S's in the list or a bunch of lengths that are all equal, so a mix 
wouldn't give
one element either. But this is a lot of calling for a simple check that could 
be written to
short-cut lots faster for the specific case or x,y,z args, e.g., (untested)

ii = isinstance; st = scalartype; ha = hasattr; L = '__len__' # save me 
typing ;-)
def __init__(self, x, y, z):
assert ii(x,st) and ii(y,st) and ii(z,st) or ha(x,L) and ha(y,L) and 
ha(z,L) and len(x)==len(y)==len(z)
...

If you wanted to check that all the elements of a passed vector x were scalars, 
you could
write (untested)
assert sum(isinstance(_, scalartype) for _ in x)==len(x)
since True==1 as a subtype of integer.

  sum(isinstance(_, scalartype) for _ in [1, 2.0, 3L])
 3
  sum(isinstance(_, scalartype) for _ in [1, 2.0, 3j])
 2
  sum(isinstance(_, scalartype) for _ in [1, 2.0, []])
 2
compared == len(thething) should work
Of course, your next step in using vectors might give you the check for free,
so no need for redundant checking. It's generally faster to let your args try 
to quack
like the ducks you need, if possible and safe.


Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Trouble with idle from python 2.4.2 on SUSE linux 9.3

2005-12-03 Thread Alasdair
I've just installed python 2.4.2 from source - it works fine from the
command line.  But when I attempt to start idle, I am told:

** IDLE can't import Tkinter.  Your Python may not be configured for
Tk. **

I have tcl 8.4 and tk 8.4 on my system; can anybody provide me with
some advice?

Sorry if this is a FAQ; I've spent some time searching the net for
helpful clues, and I am a python ultra-newbie.

Thanks,
Alasdair

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


Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread Bengt Richter
On 3 Dec 2005 19:16:10 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

I am trying to run an exe within a python script, but I'm having
trouble with spaces in the directory name.

The following example will display the usage statement of the program,
so I know that the space in the path to the exe is being handled
correctly and that the program was executed.

CMD= r'C:\program files\some directory\engine\theexe.exe'
os.system(CMD)

But the required argument for the exe require a path to a file to be
specified.  When I try to run the following, os.system(CMD2)
CMD2= r'C:\program files\some directory\engine\theexe.exe C:\program
files\some directory\engine\file.txt'

I get this error:
Unable to open file C:\Program

So, it looks to me like the space in the path for the argument is
causing it to fail.  Does anyone have any suggestions that could help
me out?
What version of windows and python are you running?
What happens if you leave out the space in the second quoted string
of CMD2? Does your program execute ok and see it?
What do you get for os.popen(CMD2).read() ?
What do you get if you make a cmd file like echoargs.cmd below
[23:29] C:\pywk\grammartype c:\util\echoargs.cmd
@echo %*

and substitute echoargs (with path if necessary) in place of your executable in 
CMD2?

Just suggestions to get more symptoms for diagnosis.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regexp non-greedy matching bug?

2005-12-03 Thread John Hazen
[Mike Meyer]
 The thing to understand is that regular expressions are *search*
 functions, that return the first parsing that matches. They search a
 space of possible matches to each term in the expression. If some term
 fails to match, the preceeding term goes on to its next match, and you
 try again. The greedy vs. non-greedy describes the order that the
 term in question tries matches. If it's greedy, it will try the
 longest possible match first. If it's non-greedy, it'll try the
 shortest possible match first.

That's a good explanation.  Thanks.

[John]
  I want to match one or two instances of a pattern in a string.
  foofoo = re.compile(r'^(foo)(.*?)(foo)?(.*?)$')

[Mike]
 First, this pattern doesn't look for one or two instances of foo in
 a string. It looks for a string that starts with foo and maybe has a
 second foo in it as well.

Right.  In simplifying the expression for public consumption, one of the
terms I dropped was r'^.*?(foo)...'.

 To do what you said you want to do, you want to use the split method:
 
 foo = re.compile('foo')
 if 2 = len(foo.split(s)) = 3:
print We had one or two 'foo's

Well, this would solve my dumbed down example, but each foo in the
original expression was a stand-in for a more complex term.  I was using
match groups to extract the parts of the match that I wanted.  Here's an
example (using Tim's correction) that actually demonstrates what I'm
doing:

 s = 'zzzfoo123barxxxfoo456baryyy'
 s2 = 'zzzfoo123barxxxfooyyy'
 foobar2 = re.compile(r'^.*?foo(\d+)bar(.*foo(\d+)bar)?.*$')
 print foobar2.match(s).group(1)
123
 print foobar2.match(s).group(3)
456
 print foobar2.match(s2).group(1)
123
 print foobar2.match(s2).group(3)
None
 


Looking at re.split, it doesn't look like it returns the actual matching
text, so I don't think that fits my need.

 As the founder of SPARE...

Hmm, not a very effective name.  A google search didn't fing any obvious
hits (even after adding the python qualifier, and removing spare time
and spare parts hits).  (I couldn't find it off your homepage,
either.)

Thanks for your help.  If you have any suggestions about a non-re way to
do the above, I'd be interested.

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


[ python-Bugs-1372650 ] Cookie and multiple names

2005-12-03 Thread SourceForge.net
Bugs item #1372650, was opened at 2005-12-03 18:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1372650group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Viraj Alankar (valankar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Cookie and multiple names

Initial Comment:
The cookie specification described here:

http://wp.netscape.com/newsref/std/cookie_spec.html

states that multiple names of cookies can be sent. This does not seem 
to parse correctly with the Cookie module due to its dictionary storage.  
When parsing cookies via modpython, only the last cookie is used. I 
think it would be better to only use the first value, since that is what 
the specification says. Or provide for a way to store multiple names 
with different paths.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1372650group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com