Re: Access denied calling FireEvent in Python

2005-04-07 Thread Jude
> > Set the "campus" listbox value and theb call fire event, such as in
> the
> > code below.  I get an "access denied" error.
Fire-events on campuses were forbidden by George W because of
terrorists might use them.
Jeff

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


Re: how can I extract all urls in a string by using re.findall() ?

2005-04-07 Thread could ildg
That's it! Thank you~~

On Apr 7, 2005 11:29 AM, Sidharth Kuruvila <[EMAIL PROTECTED]> wrote:
> Reading the documentation on re might be helpfull here :-P
> 
> findall returns a tuple of all the groups in each match.
> 
> You might find finditer usefull.
> 
> for m in re.finditer(url, html) :
> print m.group()
> 
> or you could replace all your paranthesis with the non-grouping
> version. That is, all brackets (...) with (?:...)
> 
> 
> On Apr 7, 2005 7:35 AM, could ildg <[EMAIL PROTECTED]> wrote:
> > I want to retrieve all urls in a string. When I use re.fiandall, I get
> > a list of tuples.
> > My code is like below:
> >
> > [code]
> > url=unicode(r"((http|ftp)://)?[\d]+\.)+){3}[\d]+(/[\w./]+)?)|([a-z]\w*((\.\w+)+){2,})([/][\w.~]*)*)")
> > m=re.findall(url,html)
> > for i in m:
> >print i
> > [/code]
> >
> > html is a variable of string type which contains many urls in it.
> > the code will print many tuples, and each tuple seems not to represent
> > a url. e.g, one of them is as below:
> >
> > (u'http://', u'http', u'image.zhongsou.com/image/netchina.gif', u'',
> > u'', u'', u'', u'image.zhongsou.com', u'.com', u'.com',
> > u'/netchina.gif')
> >
> > Why is there two "http" in it? and why are there so many ampty strings
> > in the tupe above? It's obviously not a url. How can I get the urls
> > correctly?
> >
> > Thanks in advance.
> > --
> > 鹦鹉聪明绝顶、搞笑之极,是人类的好朋友。
> > 直到有一天,我才发觉,我是鹦鹉。
> > 我是翻墙的鹦鹉。
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> --
> http://blogs.applibase.net/sidharth
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
鹦鹉聪明绝顶、搞笑之极,是人类的好朋友。
直到有一天,我才发觉,我是鹦鹉。
我是翻墙的鹦鹉。
--
http://mail.python.org/mailman/listinfo/python-list


client-client connection using socket

2005-04-07 Thread [EMAIL PROTECTED]
Hello,

I have two client computers, each has its own host name.
Can I do connection like socket between the two?
I check when we want to make connection we have to only put hostname
and port.
For example:

  #Server program. Could we use client hostname here ?
  HOST = ""
  PORT = 21567
  BUFSIZ = 1024
  ADDR = (HOST,PORT)
  tcpSerSock = socket(AF_INET,SOCK_STREAM)
  tcpSerSock.bind(ADDR)
  tcpSerSock.listen(5)

  while 1:
print "waiting for connection..."
tcpCliSock,addr = tcpSerSock.accept()
print "connected from:",addr
while 1:
  data = tcpCliSock.recv(BUFSIZE)
  if not data:break
  tcpCliSock.send("[%s] %s" % ctime(time()),data)
tcpCliSock.close()
  tcpSerSock.close()

  #Client program
  HOST = "fstbpc19"
  PORT = 21567
  BUFSIZ = 1024
  ADDR = (HOST,PORT)
  tcpCliSock = socket(AF_INET,SOCK_STREAM)
  tcpCliSock.connect(ADDR)
  while 1:
data = raw_input("> ")
if not data:break
tcpCliSock.send(data)
data = tcpCliSock.recv(1024)
if not data:break
print data

  tcpCliSock.close()

Sincerely Yours,
Pujo Aji

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


Re: logging as root using python script

2005-04-07 Thread Raghul
But this not the right answer

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


Re: logging as root using python script

2005-04-07 Thread Luis Bruno
Raghul wrote:

> What I need is when I execute a script it should login as root and
> execute my command and logout from root to my existing account.

I'm not sure of what you need, so I'll assume your *whole* .py script
needs root priviledges. In this case, you can configure sudo(8) or use
su(1).

For example, the script below does nothing special:

| #!/usr/bin/env python
| 
| print "Hello world!"

You can run it with higher priviledges if you use sudo(8):

$ chmod 755 hello.py
$ sudo ./hello.py

Or you can use su(1):

$ su - root -c ./hello.py

You can configure sudo(8) to not prompt for any password, BTW.

Cheers!
-- 
Luis Bruno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: client-client connection using socket

2005-04-07 Thread Laszlo Zsolt Nagy
[EMAIL PROTECTED] wrote:
Hello,
I have two client computers, each has its own host name.
 

 Hello,
I did not understand your problem. I do not see cleary what you want to do?
When you say "client", do you mean a client in a client-server architecture?
Maybe you want to create a peer-to-peer connection -- that is not the same.
 #Server program. Could we use client hostname here ?
 

Of course you can use the client's hostname. But for what purpose?
   print "connected from:",addr
 

You can do a reverse DNS lookup here to get the hostname of the client.
 #Client program
 

Ok, it seems to me that you have one client and one server. Am I wrong?
Do you want to create a connection socket between the two clients?
Is it your problem?
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: logging as root using python script

2005-04-07 Thread Martin Franklin
Luis Bruno wrote:
Raghul wrote:

What I need is when I execute a script it should login as root and
execute my command and logout from root to my existing account.

I'm not sure of what you need, so I'll assume your *whole* .py script
needs root priviledges. In this case, you can configure sudo(8) or use
su(1).
For example, the script below does nothing special:
| #!/usr/bin/env python
| 
| print "Hello world!"

You can run it with higher priviledges if you use sudo(8):
$ chmod 755 hello.py
$ sudo ./hello.py
Or you can use su(1):
$ su - root -c ./hello.py
You can configure sudo(8) to not prompt for any password, BTW.
Cheers!
another alternative would be setuid for more on this (and why it could
be a bad idea) google...
Martin

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


Re: logging as root using python script

2005-04-07 Thread Luis Bruno
Martin Franklin wrote:
> another alternative would be setuid

I also thought about making the script setuid root, but I'm under the 
impression that Linux (at least) won't honor the suid bit on a script.
That's from memory though.

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


import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
 Hi All!
I have the following structure:
/Lib/Server/Db/
   __init_.py
   DatabaseConnection.py
   Adapters/
  __init__.py
  FireBirdConnection.py
Important file contents are:
/Lib/Server/Db/__init__.py:
   import DatabaseConnection
   import Adapters
/Lib/Server/Db/DatabaseConnection.py:
   class DatabaseConnection(object):
 pass
/Lib/Server/Db/Adapters/__init__.py
   import FireBirdConnection
/Lib/Server/Db/Adapters/FireBirdConnection.py:
   from DatabaseConnection import DatabaseConnection
   class FireBirdConnection(DatabaseConnection):
  pass
Here is the problem. I go to the directory where 'Lib' resides. Then I do:
C:\Temp\ccc>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Lib
Traceback (most recent call last):
 File "", line 1, in ?
 File "Lib\__init__.py", line 1, in ?
   import Server
 File "Lib\Server\__init__.py", line 1, in ?
   import Db
 File "C:\Python\Lib\Db\__init__.py", line 29, in ?
   import  Adapters
 File "C:\Python\Lib\Db\Adapters\__init__.py", line 21, in ?
   import FireBirdConnection
 File "Db\Adapters\FireBirdConnection.py", line 27, in ?
ImportError: No module named DatabaseConnection
>>>

My problem is that Lib/Server/Db/Adapters/FireBirdConnection.py does not 
see Lib/Server/Db/DatabaseConnection.py.
Of course I read the documentation about the import statement but I do 
not see a good solution.

Possible solutions and their drawbacks:
Solution 1:
Put the 'Db' directory into my PYTHONPATH or append it to "sys.path". It 
is too bad. This could make my 'Db' module
visible but this is not a good solution. For example, I can have this 
module structure:

Lib/
   Client/
  Db/
 Adapters/
   Server/
  Db/
 Adapters/
E.g. there could be two "Db" modules, one for Client and one for Server. 
Clearly, I cannot add EVERY module path to sys.path. It would be 
ambiguous to import 'Adapters', for example.

Solution 2:
Add the outermost 'Lib' directory to sys.path and use fully qualified 
module names.  In the example above I could use this:

/Lib/Server/Db/Adapters/FireBirdConnection.py:
   from Lib.Server.Db.Adapters.DatabaseConnection import DatabaseConnection
In this case FireBirdConnection.py would be dependent on the full module 
path. Otherwise it is independent on the whole module path, it only 
depends on the 'upper level' module, regardless of its name. So here are 
the problems with this solution:

- What if I want to rename 'Server' to 'Middletire'? Should I change all 
of my files inside the 'Midletire' dir?
-What if I would like to unify the server and client Db sides? Should I 
rename "from Lib.Server.Db.Adapters.DatabaseConnection import 
DatabaseConnection" to "from Lib.Db.Adapters.DatabaseConnection import 
DatabaseConnection" in all files?
- Lastly, the import statements are too long.  They are hard to manage.

I would like to use something like
   from __uppermodule__.DatabaseConnection import DatabaseConnection
but probably there is a standard Pythoninc way to do it. Just I can't 
find it.
Maybe we can start a new PEP on this. :-)

Please advise.
p.s.: sorry for the long e-mail
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: richcmpfunc semantics

2005-04-07 Thread Greg Ewing
harold fellermann wrote:
richcmpfunc compare(PyObject *,PyObject, int);
I supposed the two objects passed are the ones to be compared.
Yes.
What is the meaning of the integer argument? Does it specify the kind
of comparision operator (e.g. __eq__ or __le__), and if so, how?

<   0

<=  1
==  2   
!=  3   

>   4

>=  5

What is my richcmpfunc supposed to return? 0 or 1 indicating False or
True?
In the usual case, yes, although it can return any
Python object. Rich comparison doesn't impose any
semantics on the operations -- this is one of the
reasons for its existence.
What has to be done, if the function is invoked for an operator
I don't want to define?
Return Py_NotImplemented. (Note that's return, *not* raise.)
Maybe there is some good documentation available, but I cannot find it.
I found most of this out by reading the source, I think.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a Perl Module from Python ( future direction of Python)

2005-04-07 Thread Greg Ewing
gf gf wrote:
Really!  That's a pity... Instead of trying to
recreate a repository the size of CPAN, a Python
interface to Perl modules is really called for.
When Parrot comes on line, this presumably will
become trivial...
--
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a Perl Module from Python ( future direction of Python)

2005-04-07 Thread Greg Ewing
By the way, is the Parrot project still alive,
or has it been given up on?
Not that I actually want it, but the idea is
kind of morbidly fascinating.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: Best editor?

2005-04-07 Thread Jussi Jumppanen
Joey C. wrote:

> When I'm using Windows, I have found the Syn TextEditor

The Zeus for Windows programmer's supports Python:

   http://www.zeusedit.com/lookmain.html

Some of the programming specific features include:

  + Code folding (supports python)
  + Integrated class browser
  + Project/workspace management
  + Fully configurable syntax highlighting
  + FTP editing
  + Integrated version control (including CVS)
  + Fully scriptable using Python, Lua, JavaScript, VbScript

But Zeus is shareware and cost $35-00 to register. It is free 
to test drive the editor as the shareware version runs fully 
functional for 60 days.

Jussi Jumppanen
Author of: Zeus for Windows (New version 3.94 out now)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting a list and counting interchanges

2005-04-07 Thread Peter Nuttall
On Wed, Apr 06, 2005 at 03:30:41PM -0700, RickMuller wrote:
> I have to sort a list, but in addition to the sorting, I need to
> compute a phase factor that is +1 if there is an even number of
> interchanges in the sort, and -1 if there is an odd number of
> interchanges.
>



I would just write a quicksort and have a counter in the swap function.
A cunning way to do it would be to multiply the counter by -1 for each
swap. if you want I can write what I had in mind. Wikipedia has a good
article of quicksort.

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


Re: richcmpfunc semantics

2005-04-07 Thread harold fellermann
Thank you Greg,
I figured most of it out in the meantime, myself. I only differ
from you in one point.
What has to be done, if the function is invoked for an operator
I don't want to define?
Return Py_NotImplemented. (Note that's return, *not* raise.)
I used
PyErr_BadArgument();
return NULL;
instead. What is the difference between the two and which one
is to prefer. Also, do you need to increment the reference count
of Py_NotImeplemented before returning it?
Thanks,
- harold -
--
I like pigs. Dogs look up to us. Cats look down to us.
Pigs treat us as equal.
-- Winston Churchill
--
http://mail.python.org/mailman/listinfo/python-list


Re: logging as root using python script

2005-04-07 Thread max . derkachev
Unixish system won't let You execute a setuid script with the setuid
privileges. Only real machine code can be executed so.
But of course, there are workarounds. When, say, you have a perl script
with setuid bit set, and sperl (setuid root perl) is installed, the
perl interpreter choses  sperl to interpret your script (sperl makes it
impossible to execute a symlink attak, which is the reason why UNIX
does not leverage privileges for setuid scripts).
So, You may write a perl suid wrapper for your python script, and let
sperl execute it.

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


doubt regarding main function

2005-04-07 Thread praba kar
Dear All,

I have doubt regarding main function in
Python.  In Python we can create a function
and we can call a function directly.
(eg:)
def test():
print 'main function test'
I can call this function the following way

eg) test()

So why we need the below way of calling a
function?

if __name__ == '__main__':
 test() 

What is the advantage of this way calling a
function.

Kindly mail me as early as possible

regards,
Prabahar




Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best editor?

2005-04-07 Thread JZ
Dnia 5 Apr 2005 11:22:59 -0700, ChinStrap napisał(a):

> Opinions on what the best is?

Eclipse + plugins: pydev (http://pydev.sourceforge.net/updates/) and
subclipse(http://subclipse.tigris.org/update/). It is free, stable,
contains integrated (visual) debugger, code completion, refactoring, PyLint
for deep analise of python code, and fine work with SVN.

For win32 lighter solution is PythownWin
(http://activestate.com/Products/ActivePython/). It's very stable, fast and
has very good debugger.

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


Re: doubt regarding main function

2005-04-07 Thread Laszlo Zsolt Nagy

if __name__ == '__main__':
test() 

What is the advantage of this way calling a
function.
 

For example, you can have a python script that has this function:
def search(keywords,engine='www.google.com')
At the end of the script, you can have this:
if __name__ == '__main__':
import sys	
print search(sys.argv[1]) 

E.g. if you run the script as a program, then you can use it for 
searching and print the results.
But you can use it as a library, like

import searchengine # This won't execute the search method because 
(searchengine.__name__ == '__main__') evaluates to False

# Use the module here
results = searchengine.search('Python')
Of course this is just one possible use. For example, you can run a self 
testing function (when not used as a module).

Best,
  Laci 2.0
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Resticted mode still active (error?)

2005-04-07 Thread Max
Not that I know of - the problem only seems to occur when using the Python C
API.
I'm trying to come up with a C programs that shows the error but it'll take
a few days to set up
the emvironment.


>"Jeff Epler" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


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


Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Gerald Klix
Hi Heiko, Hi all,
I have a PAM-library available that embedds Python.
Just tell me if you need it and I will publish it.
HTH,
Gerald
Heiko Wundram schrieb:
Hey all!
Before I start hacking away, I'm looking for a Python backend binding for 
libpam or libnss, or a python binding for the pppd plugin mechanism.

I'm trying to set up an SQL authentication scheme for virtual user accounts 
used for mail and PPTP-VPN-access, and I'd love to do the authentication bit 
in Python. And, yes, I know about pam-mysql and nss-mysql, but both projects 
are old and unmaintained, and I use Oracle as backend DB anyway.

If anybody knows of any project which has implemented a part of this, I'd love 
to hear about the effort...


--
GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Diez B. Roggisch
Heiko Wundram wrote:

> Hey all!
> 
> Before I start hacking away, I'm looking for a Python backend binding for
> libpam or libnss, or a python binding for the pppd plugin mechanism.
> 
> I'm trying to set up an SQL authentication scheme for virtual user
> accounts used for mail and PPTP-VPN-access, and I'd love to do the
> authentication bit in Python. And, yes, I know about pam-mysql and
> nss-mysql, but both projects are old and unmaintained, and I use Oracle as
> backend DB anyway.
> 
> If anybody knows of any project which has implemented a part of this, I'd
> love to hear about the effort...

I've been using pyton-pam before. Works as expected - but pam frustrated me
a bit, and you gotta run as root for it to work - a thing I didn't want to
do.

No idea for pppd.
-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Diez B. Roggisch
> I've been using pyton-pam before. Works as expected - but pam frustrated
> me a bit, and you gotta run as root for it to work - a thing I didn't want
> to do.

Ok, I just found that you wanted to play from the other side of the fence -
never mind my answer. 
-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import statement - package visibility problem

2005-04-07 Thread Kristóf Stróbl
Hi!
Laszlo Zsolt Nagy wrote:
I have the following structure:
/Lib/Server/Db/
   __init_.py
   DatabaseConnection.py
   Adapters/
  __init__.py
  FireBirdConnection.py
Important file contents are:
/Lib/Server/Db/__init__.py:
   import DatabaseConnection
   import Adapters
/Lib/Server/Db/DatabaseConnection.py:
   class DatabaseConnection(object):
 pass
/Lib/Server/Db/Adapters/__init__.py
   import FireBirdConnection
/Lib/Server/Db/Adapters/FireBirdConnection.py:
   from DatabaseConnection import DatabaseConnection
   class FireBirdConnection(DatabaseConnection):
  pass
...
My problem is that Lib/Server/Db/Adapters/FireBirdConnection.py does not 
see Lib/Server/Db/DatabaseConnection.py.
Two solutions come into my mind:
1. Do not inherit from DatabaseConnection, but pass a DatabaseConnection object 
as a parameter to the FireBirdConnection's __init__function. After this you can 
delegate the necessary functionality to the DatabaseConnection (by using 
__getattr__). This introduces less coupling between DatabaseConnection and 
FireBirdConnection, event module testing is easier.
2. Maybe the layering of your application is wrong. If DatabaseConnection 
provides common functionality to the different Adapters, it should be on the 
same layer or one beneath the Adapters.
Hard to say which can be applied to your application without knowing more about 
it, though.
Kristóf
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python sleep doesn't work right in a loop?

2005-04-07 Thread ritterhaus
I appreciate all the responses. It IS possible that wx and/or python is
whacked on my machine. I've got python 2.2 and 2.3 installed, I have
installed and uninstalled 2.4, I've had about three versions of wx
installed along the way for different programs, so it is possible that
it is just my machine.

Nevertheless, I came here looking for ideas, and you've given me some
good ones: some I had already tried (but I like validation) and some
were new to me. Thanks, all.

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


Re: Best editor?

2005-04-07 Thread Colin J. Williams
Paul McGuire wrote:
SciTE (Scintilla Text Editor) is just right for me too.  Low overhead,
great just as a Notepad alternative, but with good coding support too.
-- Paul
Yes, I use SciTE.  Syntax marking and multiple buffers. Works with 
Windows and Linux.

Boa-constructor (Scintilla based editor), aside from being a GUI 
designer, provides all of the above, with a debug capability.

PythonWin (scintilla based editor) is Windows only. It provides the 
Edit/Debug functionality of Boa and has an excellent auto-completion 
facility - this is particularly helpful when one doesn't remember the 
name or parameters of a function of method.  It currently has a bug 
which slows things down at times but, I understand that this is fixed in 
the forthcoming build 204.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Testing threading

2005-04-07 Thread Warren Postma
George Sakkis wrote:
How one goes on testing a threaded program, apart from doing a few
successful runs and crossing his fingers that it at least follows the
'correct 99.% of the time' rule ? 
If you haven't been in there and stepped through all the code, looked 
for a reasonable set of test cases, and tried those test cases, then you 
haven't tested! :-)

You test a threaded program the same way you test a non-threaded
program. Thoroughly.  Test cases. YOu don't *have* to write unit tests,
but it sure helps. Code running a few times isn't tested.  If you
prefer to test manually, really want to be thorough you have to find 
ways to make sure you've done coverage of a reasonable set of test 
cases.  How do I get myself a set of test cases? Personally I like to 
walk through my code in a debugger and ask myself "how could this go 
wrong?".  "What if I pass a huge amount of data in here? How 
unresponsive can I find ways to make this thread get?" "If this is a 
network communications thread, let's try all the various error 
conditions that can happen on a real network.". ...

When I think of an idea on how things could go wrong ("What happens if
the data isn't here or is invalid?"/"Where should I be catching 
exceptions and how should I be handling them?")

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


Re: Calling a Perl Module from Python ( future direction of Python)

2005-04-07 Thread Paul Boddie
Steve Holden <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> 
> You might also look at the work Richard Jones and others did on PyPI 
> during their PyCon sprint. Richard was confident that PyPI

Hmmm. It would appear that this information wasn't "cleared" by the PSU. ;-)

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


struct enhancements?

2005-04-07 Thread lee_merrill
Hi everyone,

I would like to be able to pack/unpack 8-byte longs, and have strings
with null padding to be able to have the nulls trimmed off
automatically.

Just thought I would mention these two items on my wish list, since I
searched a bit, and haven't yet found a mention of this...

Regards,
Lee

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


Re: struct enhancements?

2005-04-07 Thread Larry Bates
Can't address the 8-byte longs, but to strip off null padding
in strings you merely do

s=s.rstrip('\x00')

Larry Bates


[EMAIL PROTECTED] wrote:
> Hi everyone,
> 
> I would like to be able to pack/unpack 8-byte longs, and have strings
> with null padding to be able to have the nulls trimmed off
> automatically.
> 
> Just thought I would mention these two items on my wish list, since I
> searched a bit, and haven't yet found a mention of this...
> 
> Regards,
> Lee
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cross platform printing

2005-04-07 Thread Warren Postma
David Isaac wrote:
OK, I'll assume silence means "no", so new question:
What is the current best practice for cross platform printing of PostScript
files from Python?
Well since printing postscript files on most Unix systems (probably 
including Mac OSX although I don't really know this for sure) is 
trivially easy, why not investigate using cygwin  on Windows and 
launching an "lpr" task from your python script that prints the given 
postscript file. Implementation time on Unix: 0 minutes, 0 seconds. 
Implementation time on Windows; the time it takes make a cygwin batch 
file that prints using ghostscript.

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


Re: Calling a Perl Module from Python ( future direction of Python)

2005-04-07 Thread Leopold Toetsch
Greg Ewing <[EMAIL PROTECTED]> wrote:
> By the way, is the Parrot project still alive,

Of course.

leo
-- 
Apr 07 17:10:41 lux siggen[5353]: reading next random sig
Apr 07 17:10:41 lux siggen[5353]: open: /usr/bin/fortun:
Apr 07 17:10:41 lux siggen[5353]: No such file or directory
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Aahz
In article <[EMAIL PROTECTED]>,
=?iso-8859-1?Q?Fran=E7ois?= Pinard  <[EMAIL PROTECTED]> wrote:
>[Aahz]
>> [François]
>>>
>>>Many of us are using Python today, week after week, year long.  So
>>>let's be pragmatic.  Python is what it became and now is.  Let's not
>>>define it as a memory from the past nor as a futuristic dream.
>>
>> You're free to continue using 1.5.2.  [...]
>
>Sure, of course.  Yet, our friendly argument is sliding away from was it
>originally was.  The point was about not asserting in this forum that
>Python "has only one way to do it", because this is not true anymore.
>
>The principle has been, it may be back in some distant future, but now
>it is not.

You're conflating two different things:

* Whether Python currently has only one way to do things

* Whether Python has a design goal of only one way to do things

I'll agree that Python currently has many examples of more than one way
to do things (and even Python 3.0 won't remove every example, because
anything more complicated than a Turing Machine has more than one way to
do things).  But I won't agree that Only One Way has been abandoned as a
design principle.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Distributing Python Apps and MySQL

2005-04-07 Thread dcrespo
Hi there... I want to distribute my python apps and the MySQL Database
in the easiest way possible. I mean a user just run the installation
file and all is automaticly installed. Any suggestions?

My knowledge: I know, as many of you, that there's py2exe for compiling
python apps for running under Windows. But what about the database
structure and data? I think it could be reached through a .qry run in
the MySQL database from an installation instruction. But (one more
time) what about the automated installation of the MySQL database
without user intervention?

Daniel Crespo

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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Bill Mill
On Apr 7, 2005 1:15 AM, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Scott David Daniels wrote:
> > Aahz wrote:
> >
> >> You just can't have your cake and eat it, too.
> >
> > I've always wondered about this turn of phrase.  I seldom
> > eat a cake at one sitting.
> 
> You need to recursively subdivide the cake until
> you have a piece small enough to fit in your input
> buffer. Then the atomicity of the cake-ingestion
> operation will become apparent.
> 

+1 QOTW
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy

Two solutions come into my mind:
1. Do not inherit from DatabaseConnection, but pass a 
DatabaseConnection object as a parameter to the FireBirdConnection's 
__init__function. After this you can delegate the necessary 
functionality to the DatabaseConnection (by using __getattr__). This 
introduces less coupling between DatabaseConnection and 
FireBirdConnection, event module testing is easier.
I do not like this solution. I would like to use the classic 
'generalization/specialization' idiom, where the base class defines the 
interface and some common methods; while the descendants are 
specializing the basic classes. The language should allow me this 
classic approach and indeed it does.

2. Maybe the layering of your application is wrong. If 
DatabaseConnection provides common functionality to the different 
Adapters, it should be on the same layer or one beneath the Adapters.
I have a bad feeling about it. For example, I have database related 
modules under Db. I would like to implement the basic abstract classes 
at the top level, then implement the specialized classes at deeper 
levels. E.g. I can access DatabaseConnection, DatabaseSchema, 
SQLProcessor and similar classes in the top level module "Db". I would 
like to implement as much functionality in this abstract level as 
possible (reusing code is important for me). Then at some point when I 
want to implement something - for example, a connection class for 
PostgreSQL databases - then I only need to implement the unimplemented 
or extra features of a PostgreSQL connection. There can be many 
different implementations, this is why I want to store the more 
implemented (less abstracted) levels deeper in the source tree. I cannot 
imagine how could it be in the opposite direction. The abstract classes 
at the top level need to import their abstract counterparts, so I cannot 
place the abstract classes in the deepest folders - I need to place them 
at top level because they use each other very frequently. Do you 
disagree? Is this a bad design from me?

--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Read 16 bit integer complex data

2005-04-07 Thread Greg
Hi,

I'm new to python, I don't have a whole lot of programming experience
aside from Matlab.  I hope you'll excuse my ignorance.

I'm trying to figure out how to read in 16 bit integer complex data.
Each 16 bits alternate, first 16 bits represent the real part of the
number, next 16 bits represent the imaginary.

I've looked at the "unpack" command, but from what I can tell it isn't
really efficient for a large data sample.

Is there a command or method around to read in large amounts of 16 bit
complex data?

Thanks in advance for your help,

Greg

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


Re: Best editor?

2005-04-07 Thread Brian
Yes, we vi/vim users are apparently extraordinary.  Is that such a sad
thing?  ;-)

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


Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy

2. Maybe the layering of your application is wrong. If 
DatabaseConnection provides common functionality to the different 
Adapters, it should be on the same layer or one beneath the Adapters. 

Another notice. If I put 'DatabaseConnection' under 'Adapters' then it 
means that 'DatabaseConnection' is an adapter. But it is not. :-) In the 
other direction, Adapters are deeper, so adapters should can 
DatabaseConnection-s (and in fact they are).

--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy

' under 'Adapters' then it means that 'DatabaseConnection' is an 
adapter. But it is not. :-) In the other direction, Adapters are 
deeper, so adapters should can DatabaseConnection-s (and in fact they 
are).

Spelled:
In the other direction, Adapter is deeper, so adapters should _be_ 
DatabaseConnection instancess (and in fact they are)

Sorry. :-)
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Multiple inheritance: Interface problem workaround, please comment this

2005-04-07 Thread Axel Straschil
Hello!

I'm working on an HTML/Cgi widget's class where multiple inheritance
well be sometime a great thing.

I solved all my problems for pythons multiple inheritance with this ng,
thaks to all again, but there is one think I still dislike:

class A(object):
def __init__(self, a=None, **__eat): 
print "A"
super(A, self).__init__()
class B(object):

def __init__(self, b=None, **__eat): 
print "B"
super(B, self).__init__()

class AB(A, B):
def __init__(self, a=None, b=None): 
super(AB, self).__init__(a=a, b=b)

ab = AB()

This looks (and I think is) correct, but I realy dislike the **__eat
stuff. As in python everything is virtual, I found no better solution to
do that. In my real world, i've got constucts like:
class A(object)
class B(A)
class AB(A,B)
(not realy  so ugly like that ;-), just to say I can work only with super to 
call __init__).
 
My problem: If you make a coding mistake, and the mistake does not give
a runtime error becouse **__eat is a hungry evil beast, it would be very
hard to debug ... think of a wrong written parameter!

So, here is my workaround, please comment this, if someone has a better
solution I would be glad:

class A(object):
def __init__(self, a=None, _do_eat=False, **__eat): 
if __eat and not _do_eat: raise "I'm not hungry"
print "A"
super(A, self).__init__()

class B(object):
def __init__(self, b=None, _do_eat=False, **__eat): 
if __eat and not _do_eat: raise "I'm not hungry"
print "B"
super(B, self).__init__()

class AB(A, B):
def __init__(self, a=None, b=None): 
super(AB, self).__init__(a=a, b=b, _do_eat=True)

ab = AB()

Thanks, 
AXEL.
-- 
"Aber naja, ich bin eher der Forentyp." Wolfibolfi's outing in 
http://www.informatik-forum.at/showpost.php?p=206342&postcount=10
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread François Pinard
[Aahz]

> I'll agree that Python currently has many examples of more than one
> way to do things (and even Python 3.0 won't remove every example
> [...]). But I won't agree that Only One Way has been abandoned as a
> design principle.

To summarize, instead of saying "Python has only one way to do it",
rather say "Python will eventually have only one way to do it", and with
such a wording, nobody will not be mislead.

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read 16 bit integer complex data

2005-04-07 Thread Jeff Epler
You may want to use the 'numeric' or 'numarray' extensions for this.
The page on numarray is here:
http://www.stsci.edu/resources/software_hardware/numarray

numarray doesn't support "complex 16-bit integer" as a type, but you can
get a complex, floating-point valued array from your integer values.
Here's how, with a bit of explanation along the way:

I created a small example: a vector of 2 "complex 16-bit integers" 
in the native byte-order.
>>> s = struct.pack("", 1, 2, 3, 4)
>>> s
'\x01\x00\x02\x00\x03\x00\x04\x00'
I think this stands for the vector <1+2j, 3+4j> according to what you
wrote.

I can turn this into a 4-element numarray like so:
>>> numarray.fromstring(s, "s")
array([1, 2, 3, 4], type=Int16)
and extract the real and complex parts with extended slices:
>>> t[1::2] # take the items 1, 3, ..., 2*n+1 i.e., the complex parts
array([2, 4], type=Int16)

This expression forms the complex 64-bit floating point 2-element array
from 't':
>>> u = t[0::2] + t[1::2] * 1j
>>> u
array([ 1.+2.j,  3.+4.j])

If the byte-order of the file is different from the native byte order,
you can byte-swap it before forming the complex FP array:
>>> t.byteswap()
>>> t
array([ 256,  512,  768, 1024], type=Int16)


Jeff


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

Re: client-client connection using socket

2005-04-07 Thread dcrespo
"Client" and "Server" are just definitions or convention names. If your
program "listens" to connections, then it is a server. Just it.

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


Problems extracting attachment from email

2005-04-07 Thread foten
Hi community,

This is the task I'm struggling with:
- A user sends me an email with the subject '*3gp*'
  including an attached .3gp-file.
- I then fetch that email, extracts the attachement and stores
  it localy as a file.
- I then run a python-script that parses the stored file
  and generates an excel-file with statistics of that file
  at a shared driver.
  
I'm using getmail (http://pyropus.ca/software/getmail/)
(running on cygwin with cygwin python 2.4)
and the filter function provided to fetch my mail. getmail
starts my filter script and the mail is send using stdin.

I then read from stdin using
sys.stdin.read()
and the message is stored locally. The content of this stored file
is exactly the same as the mail sent to me.

I then parse that message using
fp = open(tmp_file,'rb')
p = email.Parser.Parser()

The problem I'm having is when I'm trying to extract the
attachement using
f=open(Filename, "wb")
f.write(msg.get_payload(decode=1))
f.close()
Not the whole message is decoded and stored!
When only trying
f.write(msg.get_payload())
I see that the last 255 bytes are missing.

How is this possible, I receive every last byte from stdin?

I then tried calling my windows python installation (2.4) instead of
the cygwin thingie, but that didn't work either.

Doing this using IDLE for windows or a cmdprompt for cygwin works
great!

Any ideas 'bout what I'm doing wrong here?

cheers

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


Re: Multiple inheritance: Interface problem workaround, please comment this

2005-04-07 Thread Steven Bethard
Axel Straschil wrote:
I solved all my problems for pythons multiple inheritance with this ng,
thaks to all again, but there is one think I still dislike:
class A(object):
	def __init__(self, a=None, **__eat): 
		print "A"
		super(A, self).__init__()
class B(object):

	def __init__(self, b=None, **__eat): 
		print "B"
		super(B, self).__init__()

class AB(A, B):
	def __init__(self, a=None, b=None): 
		super(AB, self).__init__(a=a, b=b)

ab = AB()
[snip]
 
My problem: If you make a coding mistake, and the mistake does not give
a runtime error becouse **__eat is a hungry evil beast, it would be very
hard to debug ... think of a wrong written parameter!
I also agree that this style is not pretty.  What are A and B in your 
real code?  I would suggest that rather than this architecture, you 
might do better to either:
   (1) make A or B a mixin class that doesn't need __init__ called, or
   (2) make class AB inherit from A and delegate to B (or vice versa)
For example:

py> class A(object):
... def __init__(self, x):
... self.x = x
...
py> class B(object):
... def __init__(self, y):
... self.y = y
...
py> class C(object):
... def m(self):
... return self.x, self.y
...
py> class ABC(A, C):
... def __init__(self, x, y):
... super(ABC, self).__init__(x)
... self._b = B(y)
... def __getattr__(self, name):
... return getattr(self._b, name)
...
py> a = ABC(1, 2)
py> a.x
1
py> a.y
2
py> a.m()
(1, 2)
Note that A is the "true" superclass, B is delegated to, and C is just a 
mixin class.

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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Ron_Adam
On 7 Apr 2005 11:11:31 -0400, [EMAIL PROTECTED] (Aahz) wrote:

>You're conflating two different things:
>
>* Whether Python currently has only one way to do things
>
>* Whether Python has a design goal of only one way to do things
>
>I'll agree that Python currently has many examples of more than one way
>to do things (and even Python 3.0 won't remove every example, because
>anything more complicated than a Turing Machine has more than one way to
>do things).  But I won't agree that Only One Way has been abandoned as a
>design principle.

I would add that the meaning is:

Python has one obvious best way to do things.

Meaning that the most obvious and clearest way, the way that comes to
mind first, will in most cases, also be the best way.

I seem to remember reading it put in that way some place at some time.


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


Re: Erroneous line number error in Py2.4.1 [Windows 2000+SP3]

2005-04-07 Thread Timo
Martin v. Löwis wrote:
> Timo wrote:
> > Does anyone have a clue what is going on?
>
> No. Please make a bug report to sf.net/projects/python.
>

Done:

http://sourceforge.net/tracker/index.php?func=detail&aid=1178484&group_id=5470&atid=105470

BR,
Timo

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


Re: logging as root using python script

2005-04-07 Thread [EMAIL PROTECTED]
use the program called 'expect'
it can be called via python.
you can build a script using the 'autoexpect' tool.
http://www.linuxjournal.com/article/3065

cheers

Raghul wrote:
> Hi
>Is it possible to login as a root in linux using python script?
> What I need is when I execute a script it should login as root and
> execute my command and logout from root to my existing account. IS is
> possible?
> 
> Thanx in advance.

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


Re: Best editor?

2005-04-07 Thread Michael George Lerner
Nicolay A. Vasiliev <[EMAIL PROTECTED]> wrote:
> Hello!

> What do you think all about ActiveState Komodo?


Is this specifically to me?  I haven't tried it, but I'm tempted.
I've recently begun teaching my wife some Python in order to help
her write a useful GUI app, and that makes it look particularly
tempting.  I'm using BoaConstructor for the GUI stuff at the moment.
It has a bit of a learning curve, but it looks nice so far.

-michael

> Michael George Lerner wrote:

> >Aahz <[EMAIL PROTECTED]> wrote:
> >
> >  
> >
> >>Use vim.  80% of the power of emacs at 20% of the learning curve.
> >>
> >>
> >
> >A system administrator said this to me about unix a long time ago,
> >but it applies equally well to emacs:
> >
> >Emacs is a great place to live, but I'd hate to visit.
> >
> >-michael, an (x)emacs user
> >
> >  
> >


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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Robin Becker
Greg Ewing wrote:
Scott David Daniels wrote:
Aahz wrote:
You just can't have your cake and eat it, too.

I've always wondered about this turn of phrase.  I seldom
eat a cake at one sitting.

You need to recursively subdivide the cake until
you have a piece small enough to fit in your input
buffer. Then the atomicity of the cake-ingestion
operation will become apparent.
Ok course according to Tarski we can cut the cake up so it increases in volume.
The slices have to be immeasurable, but the final volume can be almost anything.
I bet that makes cake buffering harder to plan for.
-paradoxically yrs-
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Steve Holden
Robin Becker wrote:
Greg Ewing wrote:
Scott David Daniels wrote:
Aahz wrote:
You just can't have your cake and eat it, too.

I've always wondered about this turn of phrase.  I seldom
eat a cake at one sitting.

You need to recursively subdivide the cake until
you have a piece small enough to fit in your input
buffer. Then the atomicity of the cake-ingestion
operation will become apparent.
Ok course according to Tarski we can cut the cake up so it increases in 
volume.
The slices have to be immeasurable, but the final volume can be almost 
anything.
I bet that makes cake buffering harder to plan for.

-paradoxically yrs-
Robin Becker
Not at all - we just apply the same division techniques to the buffer 
space until we can map the pieces of cake one-to-one onto the buffers.

stick-that-in-your-cakehole-ly y'rs  - steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: sorting a list and counting interchanges

2005-04-07 Thread Paul Rubin
Peter Nuttall <[EMAIL PROTECTED]> writes:
> I would just write a quicksort and have a counter in the swap function.
> A cunning way to do it would be to multiply the counter by -1 for each
> swap. if you want I can write what I had in mind. Wikipedia has a good
> article of quicksort.

Writing a sorting function from scratch for this purpose seems like
reinventing the wheel.  Tim's answer of simply counting the cycles
(without having to pay attention to their length) is really clever.  I
didn't realize you could do that.  Proving it is a cute exercise.
Hint: any cycle of odd length has an even number of swaps, and any
cycle of even length has an odd number of swaps (another exercise).

http://en.wikipedia.org/wiki/Even_and_odd_permutations
http://en.wikipedia.org/wiki/Permutation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python backend binding to PAM, NSS or pppd

2005-04-07 Thread Gerald Klix
Well, I am actually playing, right now. For http://www.carelix.org I 
implemented
a module that
  * adds a user to passwd and
  * authenticates that user given a certificate and some other info on 
removable media
  * it creates an encrypted loopback file, that is mounted as the 
user's home directory utilising Loop-AES and the certficate on the floppy
  * and it opens an openvpn connection using the same certificate
  * and, of course, unmounts the loopback file and terminates the vpn 
on logout.

Perhaps this is somewhat more than playing :)
cya,
Gerald
Diez B. Roggisch schrieb:
I've been using pyton-pam before. Works as expected - but pam frustrated
me a bit, and you gotta run as root for it to work - a thing I didn't want
to do.

Ok, I just found that you wanted to play from the other side of the fence -
never mind my answer. 
--
GPG-Key: http://keyserver.veridis.com:11371/search?q=0xA140D634
--
http://mail.python.org/mailman/listinfo/python-list


Re: sorting a list and counting interchanges

2005-04-07 Thread bearophileHUGS
Tim's solution is very nice, it comes from basic things often taught in
good computer science courses.

In Python when you have to do many (-1)**n you can do:
(1-2*(n%2))
This seems quite faster.

Bearophile

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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Michael Spencer
Steve Holden wrote:

Not at all - we just apply the same division techniques to the buffer 
space until we can map the pieces of cake one-to-one onto the buffers.

That technique can be applied to layer cakes, but not all real cakes.
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Frank Wilde
Ulrich Hobelmann wrote:
> alex goldman wrote:

>> I personally think GOTO was unduly criticized by Dijkstra. With the
>> benefit of hindsight, we can see that giving up GOTO in favor of
>> other primitives failed to solve the decades-old software crisis.

> The fault of goto in imperative languages is that it has no
> arguments, thus creating spaghetti of gotos and assignments.
>
> Continuations rule!

While continuations are a very interesting abstraction, the improvement
of structured programming was to be able to prove properties of your
programs in time linear to the size of the program instead of quadratic.
I don't see how giving arguments to the GOTO would help there.

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


Re: sorting a list and counting interchanges

2005-04-07 Thread Tim Peters
[Paul Rubin]
> Writing a sorting function from scratch for this purpose seems like
> reinventing the wheel.

Yup!  list.sort() is going to be mounds faster.

> Tim's answer of simply counting the cycles (without having to pay
> attention to their length) is really clever.  I didn't realize you could do
> that.

It's a standard trick; see, e.g., Nijenhuis & Wilf's "Combinatorial
Algorithms" -- although it can be hard to extract the _sense_ out of
clever Fortran <0.7 wink>.

> Proving it is a cute exercise.  Hint: any cycle of odd length has an even
> number of swaps, and any cycle of even length has an odd number of swaps
> (another exercise).

More precisely, a cycle of length c can be written as the product of
c-1 transpositions.  If the permutation is the product of m disjoint
cycles of lengths c_1, c_2, ..., c_m, then decomposing those into
transpositions gives a total number of transpositions:

(c_1-1) + (c_2-1) + ... + (c_m-1) =  [rearranging and combining the m 1's]
(c_1 + c_2 + ... + c_m) - m = [each element appears exactly once in
one cycle, since the
cycles are disjoint]
number_of_elements - m

which the code spelled

n - num_cycles

I think it's harder for some people to see why the

assert j not in seen

must be true, although that's obvious after just a few hours' thought .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sorting a list and counting interchanges

2005-04-07 Thread Bill Mill
On 7 Apr 2005 10:44:49 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Tim's solution is very nice, it comes from basic things often taught in
> good computer science courses.

I dunno, that comes from my Abstract Algebra course a heck of a lot
more than it came from any of my CS classes (I graduated last May)

While I'm at it though, I want to thank Tim for that post. It was one
of those posts where afterwards you say "of course!" but beforehand I
was totally thinking of it the wrong way. Brought me right back to
Abstract.

Peace
Bill Mill
bill.mill at gmail.com

> 
> In Python when you have to do many (-1)**n you can do:
> (1-2*(n%2))
> This seems quite faster.
> 
> Bearophile
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read 16 bit integer complex data

2005-04-07 Thread Greg
That worked, thanks a lot.
Greg

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


Manipulating Peach Tree (accounting) Btrieve database

2005-04-07 Thread Dave Boland
Has anyone used Python (or other language) to query and 
report on data in the accounting program Peach Tree?  Peach 
Tree uses a Btrieve database, but I can't be certain the 
database conforms to all of the Btrieve standards.  Some 
companies take liberties with things like that ;-).

When all is done, I need to do some good looking cross-tab 
reports and maybe make the info available by web page.

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


Use string in URLs

2005-04-07 Thread Markus Franz
Hi.
I want to use the string "rüffer" in a get-request, so I tried to encode it.
My problem: But with urllib.quote I always get "r%FCffer", but I want to 
get "r%C3%BCffer" (with is correct in my opinion).

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


Re: import statement - package visibility problem

2005-04-07 Thread Paul Clinch
Laszlo,
For :-
> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on 
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import Lib
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "Lib\__init__.py", line 1, in ?
> import Server
>   File "Lib\Server\__init__.py", line 1, in ?
> import Db
>   File "C:\Python\Lib\Db\__init__.py", line 29, in ?
> import  Adapters
>   File "C:\Python\Lib\Db\Adapters\__init__.py", line 21, in ?
> import FireBirdConnection
>   File "Db\Adapters\FireBirdConnection.py", line 27, in ?
> ImportError: No module named DatabaseConnection
>  >>>
> 
I get:
>>> import Lib
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named Lib

I guess there's a Lib/__init__.py.

But onto the point you're making. I think its possibly a mis-viewing
of the package idea in Python. A package creates a name space. If you
create Lib/Server/Db with all the __init__.py files, its because you
want to import Lib.Server.Db,  rather than a way of organising your
source files.

If you want to have a single name space, and keep the nested
arrangement of directories, you can add python code in Lib/__init__.py
to traverse directories and import packages that you find. Or you can
define any rules for mapping files and directories to the name space
you desire.

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


Re: How to detect windows shutdown

2005-04-07 Thread vincent wehren
"Austin" <[EMAIL PROTECTED]> schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
|I wrote a GUI program with wxPython.
| The error message is:
|
| Unhandled exception
| An unhandled exception occured. Press "Abort" to terminate the program,
| "Retry" to exit the program normally and "Ignore" to try to continue.
|
| Actually, besides the main program, there is another thread running
| background.
|
|
|
|
| > Austin wrote:
| >> I wrote a program running on windows.
| >> I put the link of the program in "Start up" folder and let it executed
| >> minimized.
| >> Every time when I open the computer, my program will be running in 
system
| >> tray.
| >>
| >> But if the user would like to shutdown the computer, the OS will show 
an
| >> error about exception.
| >
| > Important missing information:  is this a GUI program or
| > a console program, and if it's a GUI program, what framework
| > did you use to write it (wxPython, PyQt, other...)?  Also,
| > what is the exception that you got?  (Always report the
| > specific error: we can't guess what exception you got,
| > and the answer could well point directly to a cause that
| > is different than you think it is.)
| >
| > -Peter

Does this problem also occur when you "manually" exit the program (provided
you have a function to do so)?

If so, make sure you do something like self.tbicon.Destroy() -- with
self.tbicon being your instance of wx.TaskBarIcon() -- in your
event handler bound to wx.EVT_CLOSE.

HTH,

--

Vincent Wehren




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


Re: struct enhancements?

2005-04-07 Thread lee_merrill
Thanks! I have 16 zillion ... well 16,000 strings that need trimming.

Lee

Larry Bates wrote:
> Can't address the 8-byte longs, but to strip off null padding
> in strings you merely do
> 
> s=s.rstrip('\x00')
> 
> Larry Bates

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


Re: struct enhancements?

2005-04-07 Thread Tim Peters
[EMAIL PROTECTED]
> I would like to be able to pack/unpack 8-byte longs, ...

Have you tried struct's 'q' or 'Q' format codes?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python & MySQL

2005-04-07 Thread Andy Dustman
[EMAIL PROTECTED] wrote:
> Okay,
>
> I had the brilliant idea right after posting to google the newsgroups
> on this.
>
> db = MySQLdb.connect(user=database_user,passwd=database_password)
>
> db.autocommit(True)   <--- One little line!

You would be better off executing db.commit() periodically (at the end
of your transaction).

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


Re: sorting a list and counting interchanges

2005-04-07 Thread Bill Mill

> 
> I think it's harder for some people to see why the
> 
> assert j not in seen
> 
> must be true, although that's obvious after just a few hours' thought .

That's where you get to leave comments like:

#it follows logically that
assert j not in seen

or

#by implication
assert j not in seen

just to really frustrate the guy reading your code.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Ply(LALR) and Yacc behaving differently

2005-04-07 Thread Åsmund Grammeltvedt
Hi.

I am trying to implement a small compiler in python and, trying to use 
something a bit more pythonic than lex/yacc, ended up with ply 
(http://systems.cs.uchicago.edu/ply/). The only problem is that whereas 
yacc accepts the grammar and appears to parse it correctly, ply does not.

Perhaps this belongs on some compiler list, but I couldn't decide if it 
was a compiler or a python problem, so bear with me.

This smaller grammar illustrates the problem:

Goal ::= (+|+-)*;


The yacc grammar goes:

%start Goal
%%

Goal
  : Block ';'
;

Block
  : Empty
  | Block T
  | Block S
;

Empty
  : /* empty */
;

S
  : '+'
;

T
  : '+' '-'
;


Translated to ply:

def p_Goal(p):
"""
Goal : Block SEMI
"""

def p_Block(p):
  """
  Block : Empty
| Block T
| Block S
  """

def p_Empty(p):
"""
Empty :
"""
pass

def p_S(p):
"""
S : PLUS
"""

def p_T(p):
"""
T : PLUS MINUS
"""

Now, looking at the state machines that yacc and ply produces, the 
difference show up.

Yacc:

state 0
0 $accept: . Goal $end

$default  reduce using rule 5 (Empty)

Goal   go to state 1
Block  go to state 2
Empty  go to state 3

state 2
1 Goal: Block . ';'
3 Block: Block . T
4  | Block . S

';'  shift, and go to state 5
'+'  shift, and go to state 6

S  go to state 7
T  go to state 8

state 3
2 Block: Empty .

$default  reduce using rule 2 (Block)


Ply:

state 0

(0) S' -> . Goal
(1) Goal -> . Block SEMI
(2) Block -> . Empty
(3) Block -> . Block T
(4) Block -> . Block S
(5) Empty -> .

SEMIreduce using rule 5 (Empty -> .)

Empty  shift and go to state 3
Goal   shift and go to state 2
Block  shift and go to state 1


OK, I believe those are the interesting parts. Appearently, ply doesn't
want to shift anything other than a ';' and thereby produces an error if
it encounters '+'. This only occurs in LALR mode, though. SLR handles
correctly, but my larger grammar isn't SLR, sigh.

So, any ideas? Have I completely messed up how to handle empty productions 
or should I switch to another lexer/parser?

-- 
Åsmund Grammeltvedt

All these moments will be lost in time, like tears in the rain.
http://electricsheep.org/

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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Aahz
In article <[EMAIL PROTECTED]>,
=?iso-8859-1?Q?Fran=E7ois?= Pinard  <[EMAIL PROTECTED]> wrote:
>[Aahz]
>>
>> I'll agree that Python currently has many examples of more than one
>> way to do things (and even Python 3.0 won't remove every example
>> [...]). But I won't agree that Only One Way has been abandoned as a
>> design principle.
>
>To summarize, instead of saying "Python has only one way to do it",
>rather say "Python will eventually have only one way to do it", and with
>such a wording, nobody will not be mislead.

Let's go back to the original comments, shall we?

> [...] for Pythons ideal of having one canonical, explicit way to
> program.

No doubt it once was true, but I guess this ideal has been abandoned a
few years ago.

My honest feeling is that it would be a mis-representation of Python,
assertng today that this is still one of the Python's ideals.

Your claim that the ideal has been abandoned is just plain wrong.  In
addition, nobody has ever said "Python has only one way to do it".  The
actual principle from ``import this`` is

There should be one-- and preferably only one --obvious way to do it.

Some people have advocated that Python's motto should be "There's Only
One Way" as a counterpoint to Perl's TMTOWTDI -- but that's different
from the design principle.  Which I repeat has not been abandoned, but
should be understood to exist alongside eighteen other design principles
for Python.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web application toolkit recommendation?

2005-04-07 Thread Pierre Quentel
[EMAIL PROTECTED] a écrit :
I have looked briefly at Karrigell. does it support user logins?
S
Yes, you can take a look at the "portal" demo to see how it works
Regards,
Pierre
--
http://mail.python.org/mailman/listinfo/python-list


Re: math - need divisors algorithm

2005-04-07 Thread Peter Schorn
Philp Smith wrote:
Hi
Does anyone have suggested code for a compact, efficient, elegant, most of 
all pythonic routine to produce a list of all the proper divisors of an 
integer (given a list of prime factors/powers) 


What about
# Returns a list of all divisors of n = a1^e1*a2^e2* ... *an^en where
# input parameter l = [(a1, e1), (a2, e2), ..., (an, en)]
def divisors(l):
if  l: return [i*j for i in [l[0][0]**k for k in range(l[0][1] + 1)]
  for j in divisors(l[1:])]
else: return [1]
# divisors([(2,3),(3,2)]) == [1, 3, 9, 2, 6, 18, 4, 12, 36, 8, 24, 72]
Regards, Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Paul Clinch wrote:
   

I get:
 

import Lib
   

Traceback (most recent call last):
 File "", line 1, in ?
ImportError: No module named Lib
I guess there's a Lib/__init__.py.
 

You are totally right. I was trying to create an example but Python 
found something on my PYTHONPATH.
Sorry for the confusion, I sent a bad example. Well, could not be so bad 
because you understood the point.
I'll try to create a new good example today and make it available.

But onto the point you're making. I think its possibly a mis-viewing
of the package idea in Python. A package creates a name space. If you
create Lib/Server/Db with all the __init__.py files, its because you
want to import Lib.Server.Db,  rather than a way of organising your
source files.
 

I agree. Sometimes I need to import Lib.Server.Db but sometimes I need 
to import Lib.Server.Db.Adapters.PostgreSQLConnection.
Importing from a not package related source code is not a problem, 
really. My problem is about importing inside a package.

Lib/Server/Db/__init__.py __can__  import Lib/Server/Db/Adapters usign 
relative paths, but

Lib/Server/Db/Adapters/PostgreSQLConnection.py  __cannot__  import from 
Lib/Server/Db using relative paths

Of course I can do the latter import using absolute paths but that is 
something I would like to avoid. In other words:
it is possible to import using relative lib paths only in one direction. 
Why is that? Why can't I import something
"from the containing package"?

Why I would like to do that? Please see my reasons in my original 
e-mail. If you think that I want a programatically
bad thing, please tell me what is the right way to do it. I'm sorry if I 
look demanding.  I'm open to any suggestions.
I can hardly find a design problem in the language itself, I believe 
these problems are just mine. I have a bug in my
mind. :-) Please help me to catch it.

If you want to have a single name space, and keep the nested
arrangement of directories, you can add python code in Lib/__init__.py
to traverse directories and import packages that you find. 

Ok, in the example, you will see that this is not possible. I'm going to 
upload it soon.

Or you can define any rules for mapping files and directories to the name space
you desire.
 

How to do that? By hacking?
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: oracle interface

2005-04-07 Thread M.-A. Lemburg
Andrew Dalke wrote:
> In searching I find there several different ways to
> connect to an Oracle server on MS Windows:
> 
>   mxODBC - http://www.egenix.com/files/python/mxODBC.html
> built on top of the ODBC drivers for a given database

mxODBC works nicely with Oracl on Windows. There are
two options:

1. MS Oracle ODBC driver:

   This is the MS version of an ODBC driver for Oracle.
   It is well integrated into MS transaction managers,
   authentication and other MS techniques, but doesn't
   support all the the 8i and 9i features.

2. Oracle ODBC driver:

   This driver is supported by Oracle itself and does
   have support for 8i and 9i.

If these don't work for you, there are also a number
of commercial ODBC driver kits which support Oracle
from the usual suspects (OpenLink, EasySoft, DataDirect,
etc.).

Usage is pretty straightforward:

a) install the ODBC driver
b) create an ODBC data source (this connects the ODBC
   driver with the database you want to talk to)
c) install egenix-mx-base and egenix-mx-commercial
d) fire up Python...

from mx.ODBC.Windows import DriverConnect
dbc = DriverConnect("DSN=;UID=;PWD=")
c = dbc.cursor()
c.execute('select * from mytable')
print c.fetchall()

If you like it, contact [EMAIL PROTECTED] and we'll let you
know what else is needed :-)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 07 2005)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! 
-- 
http://mail.python.org/mailman/listinfo/python-list


How to name Exceptions that aren't Errors

2005-04-07 Thread Leo Breebaart
I've recently become rather fond of using Exceptions in Python to
signal special conditions that aren't errors, but which I feel
are better communicated up the call stack via the exception
mechanism than via e.g. return values.

For instance, I'm thinking of methods such as:


def run(self):
""" Feed the input file to the simulator. """

for linenr, line in enumerate(self.infile):
try:
current_values = self.parse_line(linenr, line)
==> except CommentLineException:
continue
results = self.do_one_simulation_step(current_values)
self.process_simulation_results(results)


which I use in order to discard comments from a file I'm parsing
line-by-line.

My question is twofold. First, I know that many programmers are
violently opposed to using exceptions in this fashion, i.e. for
anything other than, well, exceptional circumstances. But am I
correct in thinking that in Python this usage is actually
considered quite normal, and not frowned upon? Is my snippet
above indeed sufficiently Pythonic?

Second, purely as a question of aesthetics, I was wondering if
the folks here might have any opinions about actual naming
conventions for the exception classes used in this fashion.

'CommentLineError' would clearly be wrong, but using the
'Exception' prefix seems a bit redundant and pointless too. I
suppose I could just call the exception "CommentLine" and leave
it at that, but I don't know, maybe there's something better I'm
overlooking.

Any suggestions?

-- 
Leo Breebaart  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python Apps and MySQL

2005-04-07 Thread rbt
dcrespo wrote:
Hi there... I want to distribute my python apps and the MySQL Database
in the easiest way possible. I mean a user just run the installation
file and all is automaticly installed. Any suggestions?
My knowledge: I know, as many of you, that there's py2exe for compiling
python apps for running under Windows. But what about the database
structure and data? I think it could be reached through a .qry run in
the MySQL database from an installation instruction. But (one more
time) what about the automated installation of the MySQL database
without user intervention?
Daniel Crespo
I don't think one can distribute mysql within a software package w/o 
buying a commercial license to do so. Check out their licensing on their 
website here:

"When your application is not licensed under either the GPL-compatible 
Free Software License as defined by the Free Software Foundation or 
approved by OSI, and you intend to or you may distribute MySQL software, 
you must first obtain a commercial license to the MySQL product."

http://www.mysql.com/company/legal/licensing/commercial-license.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to name Exceptions that aren't Errors

2005-04-07 Thread Steve Holden
Leo Breebaart wrote:
I've recently become rather fond of using Exceptions in Python to
signal special conditions that aren't errors, but which I feel
are better communicated up the call stack via the exception
mechanism than via e.g. return values.
Absolutely.
For instance, I'm thinking of methods such as:
def run(self):
""" Feed the input file to the simulator. """
for linenr, line in enumerate(self.infile):
try:
current_values = self.parse_line(linenr, line)
==> except CommentLineException:
continue
results = self.do_one_simulation_step(current_values)
self.process_simulation_results(results)
which I use in order to discard comments from a file I'm parsing
line-by-line.
This specific example assumes that it isn't possible to easily determine 
by examination that the line is a comment, otherwise it's more readably 
re-cast as

for linenr, line in enumerate(self.infile):
if not isComment(line):
current_values = self.parse_line(linenr, line)
results = self.do_one_simulation_step(current_values)
self.process_simulation_results(results)
but the general point is still a valid one, so I'll assume you just 
grabbed something that was readily to hand.

My question is twofold. First, I know that many programmers are
violently opposed to using exceptions in this fashion, i.e. for
anything other than, well, exceptional circumstances. But am I
correct in thinking that in Python this usage is actually
considered quite normal, and not frowned upon? Is my snippet
above indeed sufficiently Pythonic?
Well, you will doubtless get as many opinions as you consult 
programmers, but in general there's much more tolerance in the Python 
world for such programming methods, and indeed much more tolerance 
generally than in some communities I've been a part of.

Second, purely as a question of aesthetics, I was wondering if
the folks here might have any opinions about actual naming
conventions for the exception classes used in this fashion.
'CommentLineError' would clearly be wrong, but using the
'Exception' prefix seems a bit redundant and pointless too. I
suppose I could just call the exception "CommentLine" and leave
it at that, but I don't know, maybe there's something better I'm
overlooking.
Here you could be guided by the standard hierarchy, quoted here from the 
2.4 documentation:

Exception
 +-- SystemExit
 +-- StopIteration
 +-- StandardError
 |+-- KeyboardInterrupt
 |+-- ImportError
 |+-- EnvironmentError
 ||+-- IOError
 ||+-- OSError
 || +-- WindowsError
 |+-- EOFError
 |+-- RuntimeError
 ||+-- NotImplementedError
 |+-- NameError
 ||+-- UnboundLocalError
 |+-- AttributeError
 |+-- SyntaxError
 ||+-- IndentationError
 || +-- TabError
 |+-- TypeError
 |+-- AssertionError
 |+-- LookupError
 ||+-- IndexError
 ||+-- KeyError
 |+-- ArithmeticError
 ||+-- OverflowError
 ||+-- ZeroDivisionError
 ||+-- FloatingPointError
 |+-- ValueError
 ||+-- UnicodeError
 ||+-- UnicodeEncodeError
 ||+-- UnicodeDecodeError
 ||+-- UnicodeTranslateError
 |+-- ReferenceError
 |+-- SystemError
 |+-- MemoryError
 +---Warning
  +-- UserWarning
  +-- DeprecationWarning
  +-- PendingDeprecationWarning
  +-- SyntaxWarning
  +-- OverflowWarning (not generated in 2.4; won't exist in 2.5)
  +-- RuntimeWarning
  +-- FutureWarning
Any suggestions?
Obviously *Error and *Warning predominate, but I would suggest it's 
largely a matter of code readability. I've even used an exception called 
Continue to overcome an irksome restriction in the language (you used 
not to be able to continue a loop from an except clause).

As long as the intent of the code is obvious to the casual reader I 
suspect it's very unlikely you'll get complaints.

except CommentLine:
pass
seems reasonably comprehensible, so time spent arguing about it would be 
better devoted to a discussion of the number of angels that could dance 
on the head of a pin.

regards
 Steve
--
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
--
http://mail.python.org/mailman/listinfo/python-list


curious problem with large numbers

2005-04-07 Thread Chris Fonnesbeck
I have been developing a python module for Markov chain Monte Carlo
estimation, in which I frequently compare variable values with a very
large number, that I arbitrarily define as:

inf = 1e1

However, on Windows (have tried on Mac, Linux) I get the following behaviour:

>>> inf = 1e1
>>> inf
1.0

while I would have expected:

1.#INF

Smaller numbers, as expected, yield:

>>> inf = 1e100
>>> inf
1e+100

Obviously, I cannot use the former to compare against large (but not
infinite) numbers, at least not to get the result I expect. Has anyone
seen this behaviour?

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


Re: How to name Exceptions that aren't Errors

2005-04-07 Thread F. Petitjean
Le 7 Apr 2005 19:23:21 GMT, Leo Breebaart a écrit :
> I've recently become rather fond of using Exceptions in Python to
> signal special conditions that aren't errors, but which I feel
> are better communicated up the call stack via the exception
> mechanism than via e.g. return values.
> 
> For instance, I'm thinking of methods such as:
> 
> 
> def run(self):
> """ Feed the input file to the simulator. """
> 
> for linenr, line in enumerate(self.infile):
> try:
> current_values = self.parse_line(linenr, line)
>==> except CommentLineException:
> continue
> results = self.do_one_simulation_step(current_values)
> self.process_simulation_results(results)
> 
> 
> which I use in order to discard comments from a file I'm parsing
> line-by-line.
> 
[snip]
> 'Exception' prefix seems a bit redundant and pointless too. I
> suppose I could just call the exception "CommentLine" and leave
> it at that, but I don't know, maybe there's something better I'm
> overlooking.
You are overlooking the fact the flow of information is pretty much
linear. The comments lines can be safely ignored (filtered out) on the
fly.
  enumerate filter-out
infile(producer) > linenr, line ---> linenr, line --->
> 
> Any suggestions?
 From your parse_line() method extract the logic to detect a comment line
put this code in a predicate function and use itertools.ifilter(pred,
iterable). Much more explicit. parse_line() is simplified. The client
code run() does not have to deal with bogus inputs anymore if you feed
it with the filtered out stream.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing Python Apps and MySQL

2005-04-07 Thread Jarek Zgoda
rbt napisał(a):
I don't think one can distribute mysql within a software package w/o 
buying a commercial license to do so. Check out their licensing on their 
website here:

"When your application is not licensed under either the GPL-compatible 
Free Software License as defined by the Free Software Foundation or 
approved by OSI, and you intend to or you may distribute MySQL software, 
you must first obtain a commercial license to the MySQL product."

http://www.mysql.com/company/legal/licensing/commercial-license.html
Don't see any legal problem here, if package is on GPL-compatible or 
OSI-approved license.

Anyway, if you want this "installer" to be multiplatform, I think you 
should write one. There are many good installer software packages for 
Windows (chief among free ones are Inno Setup and NSInstall), but I know 
only one for linux platform -- the one that XFCE uses and I don't know 
its internals, so I will speak only for Inno Setup for Windows.

It's really comprehensive tool set, as you can perform many tasks during 
installation -- you can install subpackages, perform pre- and 
post-installation steps and automate many tasks, providing they can be 
scripted. See http://www.jrsoftware.org/isinfo.php and read 
documentation, it's definitely worth this.

--
Jarek Zgoda
http://jpa.berlios.de/ | http://www.zgodowie.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problems extracting attachment from email

2005-04-07 Thread Lee Harr
On 2005-04-07, foten <[EMAIL PROTECTED]> wrote:
> The problem I'm having is when I'm trying to extract the
> attachement using
> f=open(Filename, "wb")
> f.write(msg.get_payload(decode=1))
> f.close()
> Not the whole message is decoded and stored!
> When only trying
> f.write(msg.get_payload())
> I see that the last 255 bytes are missing.
>


What happens if you do...

m = msg.get_payload(decode=1)
f.write(m)
f.write(m)
f.close()
?

Just wondering if maybe some buffer not
being flushed properly.

Maybe could replace the 2nd f.write()
with an f.flush()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import statement - package visibility problem

2005-04-07 Thread Laszlo Zsolt Nagy
Here is the example:
http://designasign.biz/Lib2.zip
Please extract the file and try to import Lib2
Although \Lib2\Client\Db\DatabaseConnection.py and 
\Lib2\Server\Db\DatabaseConnection.py  have the same class name but they 
are in a different sub-package. From a programmer's view, I hope this is 
okay.

>>> import Lib2
>>> Lib2.Server.Db.Adapters.OracleConnection


As an example of my problem, please look inside OracleConnection. You 
will see that it imports DatabaseConnection with an absolute package name:

from Lib2.Client.Db.DatabaseConnection import DatabaseConnection
so the OracleConnection.py file is dependent of its location in the 
package tree. I would like to make it independent of the full package 
tree since it only depends on 'the upper level'. I could have 10 
different types of adapters and 3 drivers for each. This is not a 
special exampe, I would like to do the same with many other classes:

- SQLProcessor (with implementations connected directly to databases, 
logging to files, printing to stdout etc)
- ReportExporter (with implementations exporting reports to excel files, 
text files, CSV files, XML files, PDF files etc.)

You can think about others but with the same structure:
- Create  the abstraction level as the upper level package and
- not just separate the implementation by a new directory but also with 
a new namespace (new sub-package).

The advantages are clear:
- Keep the implementation level and the abstraction level in well 
separated namespaces
- Do not have redundacy in the code - every module can contain 
dependencies but only to other modules/packages that are really needed 
(for example, OracleConnection should not rely on the fact that the 'Db' 
package is inside the 'Server' package. It should not even rely on that 
the name of the containing package is 'Db'. Also it should not rely on 
that the 'Lib2' package on sys.path  etc.)
- As a result, you can move a sub-package to another location without 
the need to modify possibly hundreds of files
- As a result you can move the whole package tree to anywhere and import 
it without changes in your enviroment - this can lead to interesting 
uses as well

Are these advantages good enough to start developing a magic 
'__upperpackage__' variable?

This is my dream: assuming that the containing package is already 
imported to Python, this statement:

from __upperpackage__.DatabaseConnection import DatabaseConnection
would bind '__upperpackage__' to the containing package. Of course, if 
the containing package has not been imported yet then it would raise an 
exception (ImportError: no module named __upperpackage__).

What do you think?
--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: curious problem with large numbers

2005-04-07 Thread Jeff Epler
You may want to read
http://www.python.org/peps/pep-0754.html

Part of the text reads
The IEEE 754 standard defines a set of binary representations and
algorithmic rules for floating point arithmetic. Included in the
standard is a set of constants for representing special values,
including positive infinity, negative infinity, and indeterminate or
non-numeric results (NaN). Most modern CPUs implement the IEEE 754
standard, including the (Ultra)SPARC, PowerPC, and x86 processor
series.

Currently, the handling of IEEE 754 special values in Python depends
on the underlying C library. Unfortunately, there is little
consistency between C libraries in how or whether these values are
handled. For instance, on some systems "float('Inf')" will properly
return the IEEE 754 constant for positive infinity. On many systems,
however, this expression will instead generate an error message.

Jeff


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

Re: richcmpfunc semantics

2005-04-07 Thread David M. Cooke
harold fellermann <[EMAIL PROTECTED]> writes:

> Thank you Greg,
>
> I figured most of it out in the meantime, myself. I only differ
> from you in one point.
>
>>> What has to be done, if the function is invoked for an operator
>>> I don't want to define?
>>
>> Return Py_NotImplemented. (Note that's return, *not* raise.)
>
> I used
>
> PyErr_BadArgument();
> return NULL;
>
> instead. What is the difference between the two and which one
> is to prefer.

If you do it your way you're a bad neighbour: If your object is the
first one (left-hand side) of the operator, it will prevent the other
object from handling the case if it can. This is the same advice as
for all of the other operators (__add__, etc.)

Consider the pure-python version:

class A:
def __init__(self, what_to_do='return'):
self.what_to_do = what_to_do
def __eq__(self, other):
print 'A.__eq__'
if self.what_to_do == 'return':
return NotImplemented
else:
raise Exception

class B:
def __eq__(self, other):
print 'B.__eq__'
return True

>>> a = A('return')
>>> b = B()
>>> a == b
A.__eq__
B.__eq__
True
>>> b == a
B.__eq__
True
>>> a == a
A.__eq__
A.__eq__
A.__eq__
A.__eq__
True

So the B class handles the case where A doesn't know what to do. Also
note the last case, where Python falls back on id() comparisions to
determine equality.

Now, compare with this:

>>> a = A('raise')
>>> b = B()
>>> a == b
A.__eq__
Traceback (most recent call last):
  File "", line 1, in ?
  File "x.py", line 9, in __eq__
raise Exception
Exception
>>> b == a
B.__eq__
True
>>> a == a
A.__eq__
Traceback (most recent call last):
  File "", line 1, in ?
  File "x.py", line 9, in __eq__
raise Exception
Exception

So now comparing A and B objects can fail. If you *know* A and B
objects can't be compared for equality, it'd be ok to raise a
TypeError, but that should be after a type test.

> Also, do you need to increment the reference count
> of Py_NotImeplemented before returning it?

Yes; it's a singleton like Py_None.

-- 
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to name Exceptions that aren't Errors

2005-04-07 Thread Max
Leo Breebaart wrote:
I've recently become rather fond of using Exceptions in Python to
signal special conditions that aren't errors, but which I feel
are better communicated up the call stack via the exception
mechanism than via e.g. return values.
Ummm... yeah, I quite agree.
LOOK EVERYONE, it's Leo Breebart. This guys famous in the alternative 
universe of alt.fan.pratchett.

You are the same Leo Breebart, right?
Well done, APF9 is excellent. But what did we expect.
--Max
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Terry Reedy

"Aahz" <[EMAIL PROTECTED]>

> Pinard  <[EMAIL PROTECTED]> wrote:
>>Sure, of course.  Yet, our friendly argument is sliding away from was it
>>originally was.  The point was about not asserting in this forum that
>>Python "has only one way to do it", because this is not true anymore.
>>
>>The principle has been, it may be back in some distant future, but now
>>it is not.
>
> You're conflating two different things:
>
> * Whether Python currently has only one way to do things
>
> * Whether Python has a design goal of only one way to do things
>
> I'll agree that Python currently has many examples of more than one way
> to do things (and even Python 3.0 won't remove every example, because
> anything more complicated than a Turing Machine has more than one way to
> do things).  But I won't agree that Only One Way has been abandoned as a
> design principle.

The statement in the  Zen of Python is "There should be one-- and 
preferably only one --obvious way to do it."  The splits into two related 
statements:
There should be [at least] one obvious way to do it.
There should preferably be only one obvious way to do it.

Commentary:

While 'should' can mean 'must', it can also mean something something 
softer, like desireability and preference.  In Pythonese, it has (as far as 
I know) such  softer meanings, with 'must' used when 'must is meant.  In 
the second sentence, preference is made explicit.

The presence of 'obvious' is obviously not accidental.  Without it, and 
with 'should' replaced with 'must', we eventually end up with any of 
numerous simple, possibly interesting, and mostly practically useless 
Turing-equivalent systems.  The qualifier 'obvious' does not exclude 
non-obvious ways.  For example, the obvious way, in Python, to add 1 and 2 
to get 3 is '1+2'.  Two non-obvious (certainly for the beginner) ways are 
'1 .__add__(2)' [space required] and 'import operator; operator.add(1,2)'.

Unfortunately, 'obvious' too often get elided in the discussion of this 
principle.  For some, its because it is so obviously needed that it seems 
to not need to be said.  For others, it appears to be because they are not 
fully cognizant of it.  The result can be people talking past each other. 
And, of course, obviousness is somewhat in the mind of the beholder.

The first sentence provides impetus to add new features that 'should be' 
present but are not.  At this point, that mostly means new library modules.

The second principle inhibits (but not absolutely prevents) adding 
'obvious' redundancy.  When exceptions are made, the principle of not 
breaking code prevents deleting the old except after a while and very 
occasionally.  The inhibitory principle does encourage attempts to relegate 
the old to a less obvious status by treatments in the tutorial and manuals.

The inhibitory principle is certainly still alive.  Function decorators 
barely made it past.  The proposal to extend them to classes has so far 
been rejected by GvR since class decorators seem redundant with 
metaclasses.  And lots else has been ignored or rejected.

Terry J. Reedy



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


Re: curious problem with large numbers

2005-04-07 Thread David M. Cooke
Chris Fonnesbeck <[EMAIL PROTECTED]> writes:

> I have been developing a python module for Markov chain Monte Carlo
> estimation, in which I frequently compare variable values with a very
> large number, that I arbitrarily define as:
>
> inf = 1e1
>
> However, on Windows (have tried on Mac, Linux) I get the following behaviour:
>
 inf = 1e1
 inf
> 1.0
>
> while I would have expected:
>
> 1.#INF
>
> Smaller numbers, as expected, yield:
>
 inf = 1e100
 inf
> 1e+100
>
> Obviously, I cannot use the former to compare against large (but not
> infinite) numbers, at least not to get the result I expect. Has anyone
> seen this behaviour?

I don't do Windows, so I can't say this will work, but try

>>> inf = 1e308*2

I think your problem is how the number is being parsed; perhaps
Windows is punting on all those zeros? Computing the infinity may or
may not work, but it gets around anything happening in parsing.

Alternatively, if you have numarray installed (which you should
probably consider if you're doing numerical stuff ;-) you could use

>>> import numarray.ieeespecial
>>> numarray.ieeespecial.plus_inf
inf

(there's minus_inf, nan, plus_zero, and minus_zero also)

-- 
|>|\/|<
/--\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use string in URLs

2005-04-07 Thread Leif K-Brooks
Markus Franz wrote:
I want to use the string "rüffer" in a get-request, so I tried to encode 
it.

My problem: But with urllib.quote I always get "r%FCffer", but I want to 
get "r%C3%BCffer" (with is correct in my opinion).
urllib.quote(u'rüffer'.encode('utf8'))
--
http://mail.python.org/mailman/listinfo/python-list


Re: curious problem with large numbers

2005-04-07 Thread Kristian Zoerhoff
On Apr 7, 2005 3:34 PM, David M. Cooke 
> 
> I don't do Windows, so I can't say this will work, but try
> 
> >>> inf = 1e308*2

I *do* do Windows, and that does work. The value of inf then becomes
'1.#INF' as expected. Strangely, doing

float('1.#INF')

still fails on Windows. Weird, weird.

-- 
Kristian

kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: curious problem with large numbers

2005-04-07 Thread Laszlo Zsolt Nagy
I thought it will be the same for FreeBSD, but here are the results:
FreeBSD 4.8 with Python 2.3.4
Python 2.3.4 (#2, Nov 10 2004, 05:08:39)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> inf = 1e308*2
>>> inf
Inf
>>> float('Inf')
Traceback (most recent call last):
 File "", line 1, in ?
ValueError: invalid literal for float(): Inf
>>>

FreeBSD 4.8 with Python 2.4
Python 2.4 (#2, Jan 27 2005, 17:11:08)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> inf = 1e308*2
>>> inf
Inf
>>> float('Inf')
Traceback (most recent call last):
 File "", line 1, in ?
ValueError: invalid literal for float(): Inf
>>>

--
_
 Laszlo Nagy  web: http://designasign.biz
 IT Consultantmail: [EMAIL PROTECTED]
Python forever!
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to name Exceptions that aren't Errors

2005-04-07 Thread Aahz
In article <[EMAIL PROTECTED]>,
Leo Breebaart  <[EMAIL PROTECTED]> wrote:
>
>My question is twofold. First, I know that many programmers are
>violently opposed to using exceptions in this fashion, i.e. for
>anything other than, well, exceptional circumstances. But am I correct
>in thinking that in Python this usage is actually considered quite
>normal, and not frowned upon? Is my snippet above indeed sufficiently
>Pythonic?

Consider the use of StopIteration for ``for`` loops, and you will be
Enlightened.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code -- 
not in reams of trivial code that bores the reader to death."  --GvR
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to name Exceptions that aren't Errors

2005-04-07 Thread Leo Breebaart
Max <[EMAIL PROTECTED]> writes:

> LOOK EVERYONE, it's Leo Breebart. You are the same Leo
> Breebart, right?

Breeb*aa*rt. But otherwise, yeah -- I do frequent more than just
one newsgroup. :-)


> This guys famous in the alternative universe of
> alt.fan.pratchett.

I doubt anybody here cares! Who was it that said: "On the
Internet, everyone's famous to fifteen other people"...?

Anyways, regardless of any feeble claims to notoriety I may have
in alternate universes, here in Python country I am but a humble
grasshopper wot has only been programming in Python for slightly
over a year now.

*Dutch* grasshopper, though. Does that help any?

-- 
Leo Breebaart  <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list


'Address already in use' when using socket

2005-04-07 Thread Bearish
I get 'Address already in use' errors when using sockets.
Am I properly shutting down all connections? What am I doing wrong?
I've looked at the examples and I can't figure out what I'm missing.
I already read the Python Socket HOWTO at
http://py-howto.sourceforge.net/sockets/sockets.html
but I seem to be doing everything right.

Here is the server:

#! /usr/bin/python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('localhost', 52340))
s.listen(1)
conn, addr = s.accept()
data = conn.recv(1024)
print "data:";, data
conn.close()
s.close()
print "server closed"

Here is the client:

#! /usr/bin/python
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 52340))
s.send('test string')
s.close()
print "client closed"

Here is a convenience script to run both
(although I get the same error when I run in separate shells):

#! /bin/sh
python server.py &
sleep 1
python client.py

Here is the error:

--- first time, runs just fine ---
$ source ./runboth
data: test string
server closed
client closed
[1]+  Donepython server.py
--- second time (or sometimes third time), gives error ---
$ source ./runboth
Traceback (most recent call last):
  File "server.py", line 4, in ?
s.bind(('localhost', 52340))
  File "", line 1, in bind
socket.error: (98, 'Address already in use')
[1]+  Exit 1  python server.py
Traceback (most recent call last):
  File "client.py", line 4, in ?
s.connect(('localhost', 52340))
  File "", line 1, in connect
socket.error: (111, 'Connection refused')
-- 
http://mail.python.org/mailman/listinfo/python-list


dynamic loading of code, and avoiding package/module name collisions.

2005-04-07 Thread John Perks and Sarah Mount
Long story short: what I'm looking for is information on how have a Python
app that:
* embeds an editor (or wxNoteBook full of editors)
* loads code from the editors' text pane into the app
* executes bits of it
* then later unloads to make way for an edited version of the code.
The new version needs to operate on a blank slate, so reload() may not be
appropriate.

One of the reasons I am asking is that I am writing a simulator, where the
behaviour of the objects is written in Python by the user (with callbacks
into the simulator's API to update the display). How should I best go about
this, with respect to loading (and unloading) of user code? It is expected
that each project will take the form of a Python package, with some files
therein having standard names for particular purposes (presumably
__init__.py will be one of these), and the rest being user code and data
files. It is not expected that we restrict the user's package hierarchy to
be only one level deep. Given the name of a package:

How can we be sure it doesn't conflict with a Python package/module name?

What if a new module/package is added (e.g. to site-packages) that has the
same name?

One possibility that occurred to me was having a package
MyAppName.UserProject as part of the app, with the user's project root
package occurring as a subpackage in there, and being reloaded (either via
reload() or a method on imp) each time we re-start the simulation. One
reason for this was to avoid top-level name collisions. Is this a good way
to go about it, and if so, how should users' imports refer between modules
in the same package, and across sub-packages?

Can someone please explain the interaction between the relevant parts of the
imp module (which is presumably what I'll be needing) and: the import lock;
sys.modules; sys.path?

Is removing a module from sys.modules tantamount to uninstalling it? In
particular, will imp.load_module() then create a new one?

When cheking the user's intended filenames for validity as module names, is
the canonical regexp to use
[a-zA-Z_][a-zA-Z0-9_]*, or is it something more subtle?

In general, on deciding on a module file name, how can one be sure that it
doesn't conflict with another package (either standard or third-party)? In
particular, if I have a thing.py file in my local dir, and then Python 2.5
brings out a (possibly undocumented) standard module called thing, how can I
avoid problems with running python from my local dir? (As an experiment, I
put a file called ntpath.py in my local dir, and I couldn't import site.) To
make matters worse, I may be unaware of this Python upgrade if it is done by
the sysadmin. The same applies with new keywords in Python, but this may be
ameliorated by their gradual introduction via __future__.

If all this wasn't complicated enough, at some point we'll want to let the
users write their code in Java as well (though not mixing langauges in one
project; that would make my brain hurt). Can someone point to a resource
that will list the issues we should be aware of from the start? (Googling
just gets references to Jython and jPype, rather than anything than, say, a
list of gotchas).

Thank you

John


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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Terry Reedy

"François Pinard" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

>To summarize, instead of saying "Python has only one way to do it",

As I explained in response to Aahz, what Tim Peters wrote was that Python 
'should preferably have only one obvious way to do it'.  Omission of the 
crucial qualifiers 'should preferably' and 'obvious' misleads any 
discussion.

>rather say "Python will eventually have only one way to do it",
> and with such a wording, nobody will not be mislead.

The actual design principle, as opposed to the impossible 
oversimplification, does not, in my opinion, mislead.  It is applied to 
every new proposal, most of which get rejected.  What I can't tell is 
whether you wish Python had added less new stuff or had already dumped more 
old stuff.  For myself, I wish the next version would be 3.0 and slimmed 
down a bit.

Terry J. Reedy



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


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Terry Reedy

"Ron_Adam" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Python has one obvious best way to do things.

More exactly, 'should preferably have' rather than 'has'.
>
> Meaning that the most obvious and clearest way, the way that comes to
> mind first, will in most cases, also be the best way.
>
> I seem to remember reading it put in that way some place at some time.

>>> import this # The Zen of Python

tjr



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


text processing problem

2005-04-07 Thread Maurice LING
Hi,
I'm looking for a way to do this: I need to scan a text (paragraph or 
so) and look for occurrences of " ()". That is, if the 
text just before the open bracket is the same as the text in the 
brackets, then I have to delete the brackets, with the text in it.

Does anyone knows any way to achieve this?
The closest I've seen is 
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305306) by 
Raymond Hettinger

>>> s = 'People of [planet], take us to your leader.'
>>> d = dict(planet='Earth')
>>> print convert_template(s) % d
People of Earth, take us to your leader.
>>> s = 'People of , take us to your leader.'
>>> print convert_template(s, '<', '>') % d
People of Earth, take us to your leader.
"""
import re
def convert_template(template, opener='[', closer=']'):
opener = re.escape(opener)
closer = re.escape(closer)
pattern = re.compile(opener + '([_A-Za-z][_A-Za-z0-9]*)' + closer)
return re.sub(pattern, r'%(\1)s', template.replace('%','%%'))
Cheers
Maurice
--
http://mail.python.org/mailman/listinfo/python-list


Re: Lambda: the Ultimate Design Flaw

2005-04-07 Thread Philippa Cowderoy
On Thu, 7 Apr 2005, Frank Wilde wrote:
Continuations rule!
While continuations are a very interesting abstraction, the improvement
of structured programming was to be able to prove properties of your
programs in time linear to the size of the program instead of quadratic.
I don't see how giving arguments to the GOTO would help there.
By allowing you to build your own control structures, whose properties you 
prove once before using them to prove properties in the programs that use 
them.

--
[EMAIL PROTECTED]
There is no magic bullet. There are, however, plenty of bullets that 
magically home in on feet when not used in exactly the right circumstances.
--
http://mail.python.org/mailman/listinfo/python-list


Re: 'Address already in use' when using socket

2005-04-07 Thread Peter Hansen
Bearish wrote:
I get 'Address already in use' errors when using sockets.
Generally one can fix this using:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
where "sock" is the server socket in question.  Do
this prior to attempting to bind to the port.
-Peter
--
http://mail.python.org/mailman/listinfo/python-list


Re: how can I extract all urls in a string by using re.findall() ?

2005-04-07 Thread Cappy2112
>>Reading the documentation on re might be helpfull here :-P
Many times, the python docs can make the problem more complicated,
espcecially with regexes.

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


  1   2   >