Re: PIL: The _imaging C module is not installed

2011-05-09 Thread Nico Grubert

I had this happening to me as well someday.
I recall that first installing it (python setup.py install), and then
rerunning selftest, solved that error.


I tried that as well.
Here is the summary of the install process:

build/temp.linux-x86_64-2.4/libImaging/ZipEncode.o -L/usr/local/lib 
-L/usr/lib -ljpeg -lz -o build/lib.linux-x86_64-2.4/_imaging.so
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching 
for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching 
for -lpthread

/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
building '_imagingft' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall 
-Wstrict-prototypes -fPIC -I/usr/include/freetype2 -IlibImaging 
-I/usr/local/include -I/usr/include -I/usr/local/include/python2.4 -c 
_imagingft.c -o build/temp.linux-x86_64-2.4/_imagingft.o
gcc -pthread -shared build/temp.linux-x86_64-2.4/_imagingft.o 
-L/usr/local/lib -L/usr/lib -lfreetype -o 
build/lib.linux-x86_64-2.4/_imagingft.so
/usr/bin/ld: skipping incompatible /usr/lib/libfreetype.so when 
searching for -lfreetype
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching 
for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching 
for -lpthread

/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
building '_imagingmath' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall 
-Wstrict-prototypes -fPIC -I/usr/include/freetype2 -IlibImaging 
-I/usr/local/include -I/usr/include -I/usr/local/include/python2.4 -c 
_imagingmath.c -o build/temp.linux-x86_64-2.4/_imagingmath.o
gcc -pthread -shared build/temp.linux-x86_64-2.4/_imagingmath.o 
-L/usr/local/lib -L/usr/lib -o build/lib.linux-x86_64-2.4/_imagingmath.so
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching 
for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when searching 
for -lpthread

/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc

PIL 1.1.7 SETUP SUMMARY

version   1.1.7
platform  linux2 2.4.6 (#1, Mar 16 2011, 11:33:33)
  [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)]

*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available

To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

To check the build, run the selftest.py script.
running build_scripts
creating build/scripts-2.4
copying Scripts/pilfont.py - build/scripts-2.4
copying and adjusting Scripts/pilconvert.py - build/scripts-2.4
copying and adjusting Scripts/pilfile.py - build/scripts-2.4
copying and adjusting Scripts/pilprint.py - build/scripts-2.4
copying and adjusting Scripts/pildriver.py - build/scripts-2.4
changing mode of build/scripts-2.4/pilfont.py from 644 to 755
changing mode of build/scripts-2.4/pilconvert.py from 644 to 755
changing mode of build/scripts-2.4/pilfile.py from 644 to 755
changing mode of build/scripts-2.4/pilprint.py from 644 to 755
changing mode of build/scripts-2.4/pildriver.py from 644 to 755
running install_lib
copying build/lib.linux-x86_64-2.4/_imagingft.so - 
/usr/local/lib/python2.4/site-packages/PIL
copying build/lib.linux-x86_64-2.4/_imagingmath.so - 
/usr/local/lib/python2.4/site-packages/PIL
copying build/lib.linux-x86_64-2.4/_imaging.so - 
/usr/local/lib/python2.4/site-packages/PIL

running install_scripts
copying build/scripts-2.4/pilconvert.py - /usr/local/bin
copying build/scripts-2.4/pilfile.py - /usr/local/bin
copying build/scripts-2.4/pilprint.py - /usr/local/bin
copying build/scripts-2.4/pildriver.py - /usr/local/bin
changing mode of /usr/local/bin/pilfont.py to 755
changing mode of /usr/local/bin/pilconvert.py to 755
changing mode of /usr/local/bin/pilfile.py to 755
changing mode of /usr/local/bin/pilprint.py to 755
changing mode of /usr/local/bin/pildriver.py to 755
creating /usr/local/lib/python2.4/site-packages/PIL.pth

$ python selftest.py
*** The _imaging C module is not installed


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


Re: Python-list Digest, Vol 92, Issue 40

2011-05-06 Thread Nico Grubert



PIL will compile and install if you don't have some development
libraries and then simply not work or not work up to full steam when
used.

To avoid this, you need to install the appropriate libraries, among
which are:

libjpeg-devel
freetype-devel
libpng-devel


Dear Albert

Thank you for your reply.
I did install all these libraries.
Testing it with yum shows:

$ yum install libpng-devel
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.x86_64 already installed and 
latest version
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.i386 already installed and 
latest version


$ yum install libjpeg-devel
Package libjpeg-devel-6b-37.x86_64 already installed and latest version
Package libjpeg-devel-6b-37.i386 already installed and latest version

$ yum install libpng-devel
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.x86_64 already installed and 
latest version
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.i386 already installed and 
latest version



Re-Compiling PIL shows:

$ python setup.py build_ext -i


*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available


However, running the selftest still fails:
$ python selftest.py
*** The _imaging C module is not installed

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


Re: PIL: The _imaging C module is not installed

2011-05-06 Thread Nico Grubert


 PIL will compile and install if you don't have some development
 libraries and then simply not work or not work up to full steam when
 used.

 To avoid this, you need to install the appropriate libraries, among
 which are:

 libjpeg-devel
 freetype-devel
 libpng-devel

Dear Albert

Thank you for your reply.
I did install all these libraries.
Testing it with yum shows:

$ yum install libpng-devel
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.x86_64 already installed and 
latest version
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.i386 already installed and 
latest version


$ yum install libjpeg-devel
Package libjpeg-devel-6b-37.x86_64 already installed and latest version
Package libjpeg-devel-6b-37.i386 already installed and latest version

$ yum install libpng-devel
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.x86_64 already installed and 
latest version
Package 2:libpng-devel-1.2.10-7.1.el5_5.3.i386 already installed and 
latest version



Re-Compiling PIL shows:

$ python setup.py build_ext -i


*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available


However, running the selftest still fails:
$ python selftest.py
*** The _imaging C module is not installed

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


PIL: The _imaging C module is not installed

2011-05-05 Thread Nico Grubert

Hi there

I am having trouble to install PIL 1.1.7 on CentOS.

I read and followed the instructions from
http://effbot.org/zone/pil-imaging-not-installed.htm

However, I still get the The _imaging C module is not installed error 
if I run the selftest:


$ python selftest.py
*** The _imaging C module is not installed


Here is what I have tested so far:

1.)

$ python -v
...
 import Image
...
dlopen(/usr/local/lib/python2.4/site-packages/PIL/_imaging.so, 2);
import _imaging # dynamically loaded from 
/usr/local/lib/python2.4/site-packages/PIL/_imaging.so

...

2.)

$ python
...
 import _imaging
...success imported!


Any idea what might be wrong?

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


Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert

Dear list members

I have this python list that represets a sitemap:

tree = [{'indent': 1, 'title':'Item 1', 'hassubfolder':False},
{'indent': 1, 'title':'Item 2', 'hassubfolder':False},
{'indent': 1, 'title':'Folder 1', 'hassubfolder':True},
{'indent': 2, 'title':'Sub Item 1.1', 'hassubfolder':False},
{'indent': 2, 'title':'Sub Item 1.2', 'hassubfolder':False},
{'indent': 1, 'title':'Item 3', 'hassubfolder':False},
{'indent': 1, 'title':'Folder 2', 'hassubfolder':True},
{'indent': 2, 'title':'Sub Item 2.1', 'hassubfolder':False},
{'indent': 2, 'title':'Folder 2.1', 'hassubfolder':True},
{'indent': 3, 'title':'Sub Item 2.1.1', 'hassubfolder':False},
{'indent': 3, 'title':'Sub Item 2.1.2', 'hassubfolder':False},
   ]

From that list I want to create the following HTML code:

ul id=tree
  liItem 1/li
  liItem 2/li
  liFolder 1
ul
  liSub Item 1.1/li
  liSub Item 1.2/li
/ul
  /li
  liItem 3/li
  liFolder 2
ul
  liSub Item 2.1/li
  liFolder 2.1
ul
  liSub Item 2.1.1/li
  liSub Item 2.1.2/li
/ul
  /li
/ul
  /li
/ul

If an item of the list has 'True' for the 'hassubfolder' key than a new 
ulli must be created instead of /li after its title. (See 
Folder 2 node in the HTML code above.


My problem is: How do I keep track of the closing tags while iterating 
over the python list?


Any help is much appreciated.

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


Re: Build unordered list in HTML from a python list

2010-06-30 Thread Nico Grubert

Use a stack?

Whenever you start a new list, push the corresponding closing tag onto
a stack.  Whenever your indent level decreases, pop the stack and
write out the closing tag you get.

It's straightforward to use a python list as a stack.


Thanks for the tip, Kushal.
Do you have a short code example for me?

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


Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert

Hi there

I have the following list 'mylist' that contains some dictionaries:

mylist = [{'title':'the Fog', 'id':1},
  {'title':'The Storm', 'id':2},
  {'title':'the bible', 'id':3},
  {'title':'The thunder', 'id':4}
 ]

How I can sort (case insensitive) the list by the dictioary's 'title' key?

The result should be this list:
[{'title':'the bible', 'id':3},
 {'title':'the Fog', 'id':1},
 {'title':'The Storm', 'id':2},
 {'title':'The thunder', 'id':4}
]

I am using Python 2.4.


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


Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert



Er, that should have been mylist.sort(key = lambda d:
d['title'].lower())  of course.



Thanks a lot for the tip, chris.
Unfortunately, I only have Python 2.3.5 installed and can't upgrade to 
2.4 due to an underliying application server.


In python 2.3 the 'sort()' function does not excepts any keywords 
arguments (TypeError: sort() takes no keyword arguments), so is there a 
workaround?


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


Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert

Thanks a lot Stefan  Peter.

I'm almost there (except sorting of umlauts does not work yet).


import locale

def sorted(items, key):
decorated = [(key(item), index, item) for index, item in
  enumerate(items)]
decorated.sort()
return [item[2] for item in decorated]

items = [{'title':'the Ähnlich', 'id':1},
 {'title':'The Storm', 'id':2},
 {'title':'the bible','id':3},
 {'title':'The thunder', 'id':4}]

print sorted(items, key=lambda d: locale.strxfrm(d.get('title')))

- [{'id': 2, 'title': 'The Storm'}, {'id': 4, 'title': 'The thunder'}, 
{'id': 3, 'title': 'the bible'}, {'id': 1, 'title': 'the \xc4hnlich'}]



The entry with the umlaut is the last item in but according to german 
umlaut rules it should be the first item in the result.

Do I have to set anything with the locale module?


Regards
Nico

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


Re: Sort list of dictionaries by key (case insensitive)

2010-01-13 Thread Nico Grubert



http://wiki.python.org/moin/HowTo/Sorting#Topicstobecovered


Works fine. Thanks a lot for your help, Stefan.

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


Re: ftplib timeout in Python 2.4

2009-12-18 Thread Nico Grubert

Try the timelimited function from this recipe

http://code.activestate.com/recipes/576780/



Works perfect! Thanks a lot, Jean!
--
http://mail.python.org/mailman/listinfo/python-list


ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert

Hi there,

The ftplib has a timeout parameter in Python 2.6 and above.
Is there a way to set a timeout in Python 2.4?

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


Re: ftplib timeout in Python 2.4

2009-12-17 Thread Nico Grubert

I don't know of one so you may need a workaround. What platforms do you

 need to support?

Suse Linux Enterprise 10, 64 Bit with Python 2.4.4.
I need the Python 2.4.4 for a running application Server (Zope).
--
http://mail.python.org/mailman/listinfo/python-list


Re: List of paths

2009-04-08 Thread Nico Grubert


 Here's a tricky case that doesn't show up in your example:
 In each case above, the directory names are distinct.
 how about:
['/desk', '/desk/ethanallen', '/desk/ikea',
  '/desktop', /desktop/pc', '/desktop/mac']
Should the answer be ['/desk'] or ['/desk', '/desktop'] ?

Hi Scott

good point.
It should be:

  ['/desk', '/desktop']
--
http://mail.python.org/mailman/listinfo/python-list


List of paths

2009-04-01 Thread Nico Grubert

Dear Python developers

I have the following (sorted) list.
['/notebook',
 '/notebook/mac',
 '/notebook/mac/macbook',
 '/notebook/mac/macbookpro',
 '/notebook/pc',
 '/notebook/pc/lenovo',
 '/notebook/pc/hp',
 '/notebook/pc/sony',
 '/desktop',
 '/desktop/pc/dell',
 '/desktop/mac/imac',
 '/server/hp/proliant',
 '/server/hp/proliant/385',
 '/server/hp/proliant/585'
]

I want to remove all paths x from the list if there is a path y in the 
list which is part of x so y.startswith(x) is true.


The list I want to have is:
['/notebook', '/desktop', '/server/hp/proliant']

Any idea how I can do this in Python?

Thanks in advance
Nico
--
http://mail.python.org/mailman/listinfo/python-list


Re: List of paths

2009-04-01 Thread Nico Grubert

May be not so much pythonic, but works

for i in range(len(q)):
for x in q[i:]:
   if x.startswith(q[i]) and x!=q[i]:
   q.remove(x)


...but works fine. Thanks, Eugene.
Also thanks to Andrew. Your example works fine, too. Thanks to remind me 
of the 'yield' statement! ;-)


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


Rebuild list of objects with redundancies on objects' attribute

2008-01-10 Thread Nico Grubert
Hi there

I have a list of dummy objects which have the attributes 'location', 
'name', 'gender'.
Now I want to rebuild this list in order to avoid redundancies on 
objects with the same 'location'.

Example:

#--
class Dummy:
 pass

a = Dummy()
a.location = 'tokio'
a.name = 'john'
a.gender = 'm'

b = Dummy()
b.location = 'tokio'
b.name = 'peter'
b.gender = 'm'

c = Dummy()
c.location = 'madrid'
c.name = 'susan'
c.gender = 'f'

d = Dummy()
d.location = 'london'
d.name = 'alex'
d.gender = 'm'

persons = [a, b, c, d]

print loc name   gender
print -
for obj in persons:
 print %s - %s - %s % (obj.location, obj.name, obj.gender)

#--

The output reads like this:

   loc name   gender
   -
   tokio   john   m
   tokio   peter  m
   madrid  susan  f
   london  alex   m

I want to create this list (where name and gender are lists):
   loc  name  gender
   -
   tokio[john, peter] [m]
   madrid   [susan]   [f]
   london   [alex][m]

How can I do this?


Thanks in advance.
Nico


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


Find Replace hyperlinks in a string

2007-11-26 Thread Nico Grubert
Hi there,

I have a string containing some hyperlinks. I'd like to replace every 
hyperlink with a HTML style link.

Example:

Replace
   'http://www.foo.com/any_url'
with
   'a href=http://www.foo.com/any_url;http://www.foo.com/any_url/a'


What's the best way to do this if I have a few hundret strings to check?

Thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


How to use unix_md5_crypt from Perl in Python?

2007-03-22 Thread Nico Grubert
Dear list members,

I have a Perl script which crypts a password using a clearteaxt password 
and a username.

Example:
   username = '[EMAIL PROTECTED]'
   password = 'root'

The crypted password is: 'roK20XGbWEsSM'

The crypted password always starts with the first 2 characters of the 
username (here: 'ro' from '[EMAIL PROTECTED]').

The Perl script contains this code and I am wondering how I can do this 
in Python:
#
my $CryptedPw = '';
# md5 pw
if ($Self-{ConfigObject}-Get('AuthModule::DB::CryptType') 
 $Self-{ConfigObject}-Get('AuthModule::DB::CryptType') eq 'md5') {
 $CryptedPw = unix_md5_crypt($Pw, $Param{UserLogin});
}
# crypt pw
else {
 # crypt given pw (unfortunately there is a mod_perl2 bug
 # on RH8 - check if
 # crypt() is working correctly) :-/
 if (crypt('root', '[EMAIL PROTECTED]') eq 'roK20XGbWEsSM') {
 $CryptedPw = crypt($Pw, $Param{UserLogin});
 }
 else {
 $Self-{LogObject}-Log(
 Priority = 'notice',
 Message = The crypt() of your mod_perl(2) is not working 
correctly! Update mod_perl!,
 );
 my $TempUser = quotemeta($Param{UserLogin});
 my $TempPw = quotemeta($Pw);
 my $CMD = perl -e \print crypt('$TempPw', '$TempUser');\;
 open (IO,  $CMD | ) || print STDERR Can't open $CMD: $!;
 while (IO) {
 $CryptedPw .= $_;
 }
 close (IO);
 chomp $CryptedPw;
 }
}
#


What do I have to do in Python to create the crypted password 
'roK20XGbWEsSM' by using '[EMAIL PROTECTED]' for username and 'root' for 
password?

I tried:
  username = '[EMAIL PROTECTED]'
  password = 'root'
  import crypt
  crypt.crypt(username, password)
'roowueH.vq6VM'
 

This creates 'roowueH.vq6VM' but not 'roK20XGbWEsSM'. :-(

Thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Python's email module - problem with umlauts in some email clients

2006-12-08 Thread Nico Grubert
Hi there,

I wrote a short python script that sends an email using python's email 
module and I am using Python 2.3.5.
The problem is, that umlauts are not displayed properly in some email 
clients:

+ On a windows machine running thunderbird 1.0.2 umlauts are displayed
   properly.
   The email header contains Content-type: text/plain; charset=utf-8
   so the email client's character encoding automatically switches to
   Unicode (UTF-8)

+ On a solaris machine running thunderbird 1.5.0.8 and on a macintosh
   machine running eudora umlauts are *not* displayed properly.
   The email header does not contain any Content-type. If I manually
   switch the email client's character encoding to Unicode (UTF-8), the
   umlauts are displayed properly. Therefore, I guess it has something to
   do with the missing Content-type: text/plain; charset=utf-8
   information in the email header.

Any idea why the Content-type: text/plain; charset=utf-8 is missing?


Here is my script:

#--
# send email
from email.Header import Header
import email.Message
import email.Utils
import mimetypes
from smtplib import SMTP

host = 'mail.example.com'
mFrom = '[EMAIL PROTECTED]'
mTo = '[EMAIL PROTECTED]'
mSubj = u'f\xfcr'
mBody = u'f\xfcr foo bar'
mBody = mBody.encode('UTF-8')

mainMsg = email.Message.Message()

mainMsg['From'] = mFrom
mainMsg['To'] = mTo
mainMsg['Subject'] = mSubj
mainMsg.set_payload(mBody)

mainMsg['Date'] = email.Utils.formatdate(localtime=1)
mainMsg['Message-ID'] = email.Utils.make_msgid()
mainMsg['Mime-version'] = '1.0'
mainMsg['Content-type'] = 'text/plain; charset=utf-8'
mainMsg['Content-transfer-encoding'] = '8bit'
# 'quoted-printable' does not work either
# mainMsg['Content-Transfer-Encoding'] = 'quoted-printable'

s = SMTP(host)
s.sendmail(mFrom, [mTo], mainMsg.as_string())
s.close()
#--

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


ldapsearch example in python-ldap?

2006-11-23 Thread Nico Grubert
Hi there,

on a linux machine I am running this ldapsearch from the command line:

ldapsearch -x -h myldaphost.mydomain.com \
   -D CN=ldapuser,CN=Users,DC=mydomain,DC=com -w secret \
   -b CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=com

How can I do this with python-ldap?

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


PIL on Python 2.4 - ImportError: No module named _imagingft

2006-10-31 Thread Nico Grubert
Dear list members,

I have installed Python 2.4.3. and PIL 1.1.5. on a Suse Linux 10 64 Bit 
machine.

If I try

   import _imagingft

I get this error:
   ImportError: No module named _imagingft

Did I miss something?
On my 32 But Linux with Python 2.3.5. everything works fine.

Kind regards,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL on Python 2.4 - ImportError: No module named _imagingft [Solved]

2006-10-31 Thread Nico Grubert
 If I try
 
   import _imagingft
 
 I get this error:
   ImportError: No module named _imagingft
 
 Did I miss something?

Yes, I did. Somehow, there was no _imagingft.so in the PIL directory.
-- 
http://mail.python.org/mailman/listinfo/python-list


Convert binary image to JPEG with 72 dpi

2006-10-20 Thread Nico Grubert
Dear list members,I have the binary content of an image file and it's filename.I neither know the resolution nor the dpi of the image.No I need to convert this binary content into a 72 dpi jpeg image.
Furthermore I have to resize the image so neither the width nor the height is bigger than 250 pixels. I'd like to use PIL for this job. Any tips how to do it?Regards, Nico
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python on a 64-Bit OS

2006-09-21 Thread Nico Grubert
 Several changes have been made to Python 2.4 and 2.5 to support
 AMD64-Linux better, and not all of these changes have been
 incorporated into Python 2.3, as this software is no longer
 maintained.

 As others have said: you should really try to use the python 2.4
 that comes with the operating system. Can you share the reason why
 you have to use Python 2.3?

I actually should use the Python 2.3.5 for an application server called 
  Zope and a Zope product that officially does not support the latest 
Zope version yet. The latest stable Zope version requires  Python 2.4.2 
so I'll installed Python 2.4.3. and I am trying to get it running.

Thanks for the tips.

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


Installing Python on a 64-Bit OS

2006-09-19 Thread Nico Grubert
Hi there,

I'd like to install Python 2.3.5. on a 64-Bit OS (Suse Linux Enterprise 
Server 10) on an AMD Opteron 64-Bit machine.
I have to use Python 2.3.5.

Do I need a special source archive or can I use Python-2.3.5.tgz from 
http://www.python.org/ftp/python/2.3.5/Python-2.3.5.tgz ?

Is there anything special I have to care about or is installing Python 
on a 64 Bit OS just as easy as installing it on a 32-Bit OS?

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


Re: Searching a string and extract all occurancies of a substring

2006-09-01 Thread Nico Grubert

 is this XML, or just something that looks a little like XML ?

Unfortunately, something that looks a little XML so I can't use a XML 
parser. But the HTML parser does the job.
-- 
http://mail.python.org/mailman/listinfo/python-list


Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
Hi there,

in a text with no carriage returns I need to look for all occurancies of 
this string:

source id=boxparameter key=path.../parameter/source

The ... can contain different values. I need to extract the string 
between source id=boxparameter key=path and /parameter/source.

Example text:
This is a test. link url=/www/folder target=_self title= A test. 
source id=boxparameter key=path/www/mydoc1/parameter/source 
And I need to extraxt /www/mydoc1 and /www/mydoc2 from this text.
source id=boxparameter key=path/foo/bar/doc/parameter/source

 From this text I need to get a list with this:
  [/www/mydoc1, /foo/bar/doc]

What's the best way to do this?


I'll need to use Python: 2.3.5

Thanks in advance,
Nico

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


Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert

 Try Beautiful Soup, or if your input is simple enough, the re module.

Hi Gabriel,

I first tried HTMLParser and wrote this short script:

from HTMLParser import HTMLParser
from htmlentitydefs import entitydefs

class MyDocParser(HTMLParser):

 def __init__(self):
 self.paths = []
 self.readingpaths = 0 # flag
 HTMLParser.__init__(self)

 def handle_starttag(self, tag, attrs):
 if tag == 'parameter':
 self.readingpaths = 1

 def handle_endtag(self, tag):
 if tag == 'parameter':
 self.readingpaths = 0

 def handle_data(self, data):
 if self.readingpaths:
 self.paths.append(data)

 def handle_entityref(self, name):
  handle values like 'Home amp; Products' 
 if entitydefs.has_key(name):
 self.handle_data(entitydefs[name])
 else:
 self.handle_data('' + name + ';')

 def handle_charref(self, name):
  handle values like 'Home amp; Products#174;'
 Ignores invalid character references
 
 try:
 charnum = int(name)
 except ValueError:
 return

 if charnum  1 or charnum  255:
 return

 def get_paths(self):
 return self.paths


def parse_content(content):
  parse
 

 parser = MyDocParser()
 parser.feed(content)

 paths = parser.get_paths()

 return paths

# /end

This works as long as there are no other paramter Tags in the content 
that I parse.


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


Re: Searching a string and extract all occurancies of a substring

2006-08-31 Thread Nico Grubert
 This works as long as there are no other paramter Tags in the content 
 that I parse.

Got it.

I forgot to handle the 'attrs' parameter in handle_starttag().

Changed it to:

 def handle_starttag(self, tag, attrs):
 if tag == 'parameter':
 if attrs == [('key', 'infobox_path')]:
 self.readingpaths = 1

This works so far.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to change the path for python binary?

2006-08-10 Thread Nico Grubert
Hi there,

I have installed Python 2.3.5 on Suse Linux 10.
If I enter python in the shell, the Python 2.3.5 interpreter is called.

After I installed Python 2.4.3. the Python 2.4.3 interpreter is called 
which is the default behaviour I guess.

which python brings me /usr/local/bin/python which calls the Python 
2.4.3 interpreter.

My question now is:
What do I have to do in order to get the Python 2.3.5 interpreter each 
time I enter python in the shell?

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


Search substring in a string and get index of all occurances

2006-06-21 Thread Nico Grubert
Hi there,

I would like to search for a substring in a string and get the index of 
all occurances.

mystring = 'John has a really nice powerbook.'
substr = ' '  # space

I would like to get this list:
   [4, 8, 10, 17, 22]

How can I do that without using for i in mystring which might be 
expensive for large strings?

Thanks in advance,
  Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.popen3() - how to close cmd window automatically?

2006-06-01 Thread Nico Grubert
 replace console=[... by windows=[... in your setup.py

Works perfect. Thank you, Rony!
-- 
http://mail.python.org/mailman/listinfo/python-list


os.popen3() - how to close cmd window automatically?

2006-05-31 Thread Nico Grubert
Dear Python developers,

I use a short python script in order to run an external application plus 
to open a browser displaying a default page.

My Setup: Python 2.4.3. / Windows2000

# --
# Script shortcut.py
import os
import webbrowser
import win32api

# open default web browser and display webbpage
page = 'C:\\Temp\\Welcome.html'
webbrowser.open(page)

# path to application that is opened
path = C:\\Program Files\\ExternalApplication.exe

# get short name
shortpath = win32api.GetShortPathName(path)

# open external application
stdin, stdout, stderr = os.popen3(shortpath)
output = stdout.read()
errors = stderr.read()
stdin.close()
stdout.close()
stderr.close()
print output
print errors
# --


In order to make this Script available on other Windows2000 machines 
where no Python installation is present, I made this script executable 
using py2exe (http://www.py2exe.org/). This creates a shortcut.exe file.
If I run shortcut.exe everything works fine but a black empty cmd 
window opens and its kept open until I close the application 
ExternalApplication.exe.
How can I close that black empty window automatically?

Thanks in advance,
   Nico


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


Re: How to open https Site and pass request?

2006-05-24 Thread Nico Grubert
 That depends on your OS.  In Windows, I believe you would have to
 recompile Python from source.  On Linux, you could probably just get a
 package.  From Debian, I know that it's python-ssl.  I'm sure most the
 others would have one as well.

Hi Jerry,

thank you for your reply. I use Linux and installed the package 
python-openssl which allows me to import the module OpenSSL
(import OpenSSL) but I think installing this package has nothing to do 
with the SSL support of my python installation. Is that true?

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


Re: How to find out a date/time difference

2006-05-24 Thread Nico Grubert


  I use  datetime class in my program and now
  I have two fields that have the datetime format like this
  datetime.datetime(2006, 5, 24, 16, 1, 26)

  How can I find out the date/time difference ( in days) of such two
  fields?

Hi Lad,

you could do this:

  a = datetime.datetime(2006, 5, 24, 16, 1, 26)
  b = datetime.datetime(2006, 5, 20, 12, 1, 26)
  a-b
datetime.timedelta(4)
# 4 days

  b = datetime.datetime(2006, 5, 20, 12, 1, 26)
  x = a-b
  x
datetime.timedelta(4, 14400)
  str(x)
'4 days, 4:00:00'


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


How to open https Site and pass request?

2006-05-23 Thread Nico Grubert
Hi there,

I am trying to open an https site and pass a request to it in order to 
simulate the submit of an HTML form on a https site that sets an 
authentication cookie for a tomcat application, so the the URL I am 
trying to open points to a web form provided by the tomcat webserver.

I tried (Python 2.3.5):

  import urllib
  import urllib2
  the_url = https://myserver/application/login.do;
  user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
  headers = { 'User-Agent' : user_agent }
  values = { 'username' : 'myuser', 'password' : 'mypasswd' }
  data = urllib.urlencode(values)
  req = urllib2.Request(the_url, data)
  handle = urllib2.urlopen(req)

This raises the following exception:

Traceback (most recent call last):
   File stdin, line 1, in ?
   File /usr/local/lib/python2.3/urllib2.py, line 129, in urlopen
 return _opener.open(url, data)
   File /usr/local/lib/python2.3/urllib2.py, line 331, in open
 'unknown_open', req)
   File /usr/local/lib/python2.3/urllib2.py, line 306, in _call_chain
 result = func(*args)
   File /usr/local/lib/python2.3/urllib2.py, line 914, in unknown_open
 raise URLError('unknown url type: %s' % type)
urllib2.URLError: urlopen error unknown url type: https


Any idea, what I did wrong?

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


Re: How to open https Site and pass request?

2006-05-23 Thread Nico Grubert
   import urllib
   import urllib2
   the_url = https://myserver/application/login.do;
   user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
   headers = { 'User-Agent' : user_agent }
   values = { 'username' : 'myuser', 'password' : 'mypasswd' }
   data = urllib.urlencode(values)
   req = urllib2.Request(the_url, data)
   handle = urllib2.urlopen(req)

 urllib2.URLError: urlopen error unknown url type: https

To answer my question myself:
My python installation does not have SSL support (from socket import ssl
  failed). I tested the same code on another machine and it's working.

However, I am wondering how I can additionally enable SSL support for my 
python installation ?

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


Re: Zope Guru...

2006-05-04 Thread Nico Grubert
  In doing some research into Workflow apps regarding document
  management, I came across Zope. Given that it's Python Based, I
  figured I'd shout to the group here...

If you want to develop an application with Zope+Python from scratch, 
there are a few Zope products out there that handle workflow 
(DCWorkflow, Openflow).

If you look for an existing Zope based DMS, you might want to look at 
the Document Library application which has been released yesterday by 
infrae. http://www.infrae.com/download/documentlibrary

Another existing Zope based application for document
  management including workflow is Plone. http://www.plone.org

If you plan to start using Zope 3, you might want to take a look at 
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Workflow


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


Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Nico Grubert
Hi there,

I am looking for a way to sort a list containing dictionaries.

This is my example list:
[{'Title': 'ABC', 'from_datetime': DateTime('2006/04/25 12:45:00 
GMT+2')}, {'Title': 'DEF', 'from_datetime': DateTime('2006/04/18 
12:45:00 GMT+2')}, {'Title': 'GHI', 'from_datetime': 
DateTime('2006/03/10 12:45:00 GMT+2')}]

I want to sort the list by dictionary's key 'from_datetime' so the 
sorted list should be:

[{'Title': 'GHI', 'from_datetime': DateTime('2006/03/10 12:45:00 
GMT+2')}, {'Title': 'DEF', 'from_datetime': DateTime('2006/04/18 
12:45:00 GMT+2')}, {'Title': 'ABC', 'from_datetime': 
DateTime('2006/04/25 12:45:00 GMT+2')}]

Any idea how I can sort this list?


Thank you very much in advance,
   Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Nico Grubert
 assuming that DateTime returns something that compares correctly, you can
 do something like:
 
 def sortkey(item):
 return item.get(from_datetime)
 
 data.sort(key=sortkey)
 
 (assuming Python 2.4 or later)

Thank you very much, Frederik. Unfortunately, I can only use Python 2.3.5.
-- 
http://mail.python.org/mailman/listinfo/python-list


Splitting a string

2006-02-13 Thread Nico Grubert
Dear Python users,

I'd like to split a string where 'and', 'or', 'and not' occurs.

Example string:
s = 'Smith, R. OR White OR Blue, T. AND Black AND Red AND NOT Green'

I need to split s in order to get this list:
['Smith, R.', 'White', 'Blue, T.', 'Back', 'Red', 'Green']

Any idea, how I can split a string where 'and', 'or', 'and not' occurs?


Thank you very much in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-soappy

2006-01-11 Thread Nico Grubert
  can anybody point me to a tutorial, howto or example code of
  python-soappy...? google did not have really useful results about...

This might be helpful:
  http://www-128.ibm.com/developerworks/library/ws-pyth5/
  http://users.skynet.be/pascalbotte/rcx-ws-doc/python.htm

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


String question - find all possible versions of a person's firstname

2006-01-10 Thread Nico Grubert
Hi there,

I have a string 'Michèle' that represents the firstname of a person.

What's the best way to get all possible versions of this name if I 
consider to use these characters: e, è, é, ê

I'd like to have a function that returns a list of the following names 
when passing 'Michèle' as parameter to it:

'Michele'
'Michelè'
'Michelé'
'Michelê'

'Michêle'
'Michêlè'
'Michêlé'
'Michêlê'

'Michèle'
'Michèlè'
'Michèlé'
'Michèlê'

'Michéle'
'Michélè'
'Michélé'
'Michélê'


Thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String question - find all possible versions of a person's firstname

2006-01-10 Thread Nico Grubert
 This sounds like a homework problem.  You might try splitting the name
 at the e's, check the length of the resulting list and do that many
 nested loops.

This was my idea too but I am wondering if there are any scripts for 
tasks like this.

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


How to ping in Python?

2005-12-05 Thread Nico Grubert
Hi there,

I could not find any ping Class or Handler in python (2.3.5) to ping a 
machine.
I just need to ping a machine to see if its answering. What's the best 
way to do it?

Kind regards,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
 add
 
 ftp.set_debuglevel(3)
 
 so you can see what the goes on the wire (without that information, it's hard
 to tell if it's a bug in the library or a glitch in your server).
 
 /F 

Hello Fredrik ,

thank you for your reply. I did a ftp.set_debuglevel(3) and ftp.nlst() 
now prints:

  ftp.nlst()
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to I.\r\n'
*resp* '200 Type set to I.'
*cmd* 'PORT 10,30,1,31,128,129'
*put* 'PORT 10,30,1,31,128,129\r\n'
*get* '200 PORT command Ok.\r\n'
*resp* '200 PORT command Ok.'
*cmd* 'NLST'
*put* 'NLST\r\n'
*get* '150 About to open data connection.\r\n'
*resp* '150 About to open data connection.'
*retr* ''
*get* '226 Transfer complete.\r\n'
*resp* '226 Transfer complete.'
[]
 

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


Re: ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-25 Thread Nico Grubert
  it's not obvious how Python could translate '' to anything other
  than an empty list, so it sure looks like a server issue.

  (or is a problem with running in passive mode?  can you test with-
  out using passive mode on the same server?)


I thought using ftp.set_pasv(0) sets active mode so I can use 
ftp.anyMethod() wihtout using passive mode?

I tried:

  ftp.set_pasv(0)
  ftp.nlst()
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to I.\r\n'
*resp* '200 Type set to I.'
*cmd* 'PORT 10,30,1,31,128,19'
*put* 'PORT 10,30,1,31,128,19\r\n'
*get* '200 PORT command Ok.\r\n'
*resp* '200 PORT command Ok.'
*cmd* 'NLST'
*put* 'NLST\r\n'
*get* '150 About to open data connection.\r\n'
*resp* '150 About to open data connection.'
*retr* ''
*get* '226 Transfer complete.\r\n'
*resp* '226 Transfer complete.'
[]
  ftp.dir()
-r--r--r--   1 ownergroup  121984 Nov 24 12:13 member.dat
-r--r--r--   1 ownergroup 115 Nov 24 15:53 status.dat
-r--r--r--   1 ownergroup 339 Nov 24 15:53 debug.txt
 


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


ftplib question - ftp.dir() returns something and ftp.nlst() does not

2005-11-24 Thread Nico Grubert
Hi there,

I am using the ftplib library to connect to a ftp server.
After I got connected, I can see a list of file in the current directory 
using ftp.dir() or ftp.retrlines('LIST'). But using ftp.nlst() returns 
an empty list which seems somehow strange to me. Here is, what I did:

  from ftplib import FTP
  HOST = 'my.server'
  USER = 'myuser'
  PASSWD = 'mypass'
  ftp = FTP(HOST, USER, PASSWD)
  ftp.set_pasv(0) # set active mode
  ftp.dir()
-r--r--r--   1 ownergroup  121984 Nov 24 12:13 member.dat
-r--r--r--   1 ownergroup 115 Nov 24 15:53 status.dat
-r--r--r--   1 ownergroup 339 Nov 24 15:53 debug.txt
 
  ftp.retrlines('LIST')
-r--r--r--   1 ownergroup  121984 Nov 24 12:13 member.dat
-r--r--r--   1 ownergroup 115 Nov 24 15:53 status.dat
-r--r--r--   1 ownergroup 339 Nov 24 15:53 debug.txt
'226 Transfer complete.'
 
  ftp.nlst()
[]
 

I thought ftp.nlst() would return the list ['member.dat', 
'status.dat', 'debug.txt']. Any idea, what is going wrong here?

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


Question about parsing a string

2005-10-10 Thread Nico Grubert
Hi there,

I would like to parse a string in Python.

If the string is e.g. '[url=http://www.whatever.org][/url]' I would like 
to generate this string:
'a href=http://www.whatever.org;http://www.whatever.org/a'

If the string is e.g. '[url=http://www.whatever.org]My link[/url]' I 
would like to generate this string:
'a href=http://www.whatever.org;My link/a'

Any idea how I can do this? Maybe with regular expressions?

Thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


How to use a timer in Python?

2005-09-23 Thread Nico Grubert
Hi there,

on a Linux machine running Python 2.3.5. I want to create a file 
'newfile' in a directory '/tmp' only if there is no file 'transfer.lock' 
in '/temp'.
A cronjob creates a file 'transfer.lock' in '/temp' directory every 15 
minutes while the cronjob is doing something. This job takes around 30 
seconds. During these 30 seconds the 'transfer.lock' file is present in 
the '/temp' directory and I must not create 'newfile'. After the cronjob 
has been finished, the 'transfer.lock' file is deleted from '/temp' and 
I can create 'newfile'.
How can I use a timer that waits e.g. 10 seconds if 'transfer.lock' is 
present and then checks again if 'transfer.lock' is still there?

I want to do something like this:

import os
if 'transfer.lock' in os.listdir('/temp'):
   # ...wait 10 seconds and then check again if
   # 'transfer.lock' is in os.listdir('/temp')
else:
   # create 'newfile'


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


Re: How to use a timer in Python?

2005-09-23 Thread Nico Grubert
Hi Sybren and Wolfram,

thank you very much for the time.sleep() tip.
My program reads like this now.

import os
import time
WINDOWS_SHARE = 'C:\\Temp'
while 'transfer.lock' in os.listdir( WINDOWS_SHARE ):
 print Busy, please wait...
 time.sleep(10)

f = open(WINDOWS_SHARE + '/myfile', 'w')
f.write(test 123)
f.close()
print Done!


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


Re: How to use a timer in Python?

2005-09-23 Thread Nico Grubert
 That all sounds very race-y to me!  The cron-job and the other process
 need to take the same lock, otherwise the cron-job will start 1ms
 after the other process checks for transfer.lock and before it has a
 chance to create newfile and there will be trouble.
 
 Using files as locks isn't brilliant because the operations read to
 see if the lock is there and create the file isn't aren't atomic.
 Ie someone can get in there after you read the directory but before
 you create the file.
 
 However creating a directory is atomic, so you can take the lock by
 os.mkdir(/tmp/lock).  If that succeeded you got the lock, if it
 failed (threw OSError) then you didn't.  If it failed then just
 time.sleep(1) and try again.  This kind of locking works cross
 platform too.  You can use it in shell too, eg mkdir /tmp/lock ||
 exit 1 in your cronjob.

There is no cronjob anymore now. I just need to check if there is a lock 
file. How would you modify my short program to avoid the situation Ie 
someone can get in there after you read the directory but before
you create the file.?

Nico

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


How to use writelines to append new lines to an existing file

2005-09-22 Thread Nico Grubert
Hi there,

I would like to open an existing file that contains some lines of text 
in order to append a new line at the end of the content.

My first try was:

  f = open('/tmp/myfile', 'w') #create new file for writing
  f.writelines('123') #write first line
  f.close()
  f = open('/tmp/myfile', 'w') #open existing file to append new line
  f.writelines('456')
  f.close()
  f = open('/tmp/myfile', 'r') # open file for reading
  f.read()
'456'

I supposed to have:
  f.read()
'123\n456\n'


Does  f = open('/tmp/myfile', 'w')  overwrite the existing file or does 
f.writelines('456') replace the first line in the existing file?

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


How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
Hi there,

I would like to copy a file from one machine (machine #01) to another 
(machine #02).

machine #01: Suse Linux 9.2, Samba 3, Python 2.3.5
machine #02: Windows Machine, Destination Dir: Share\temp\files\

Both machines are in one network so they can communicate each other. In 
order to be able to write a file in the directory on Machine #02 I need 
to be the user myadmin.

In a short Python program I create the source file on Machine #01 like this:

filecontent = 'This is just a test...'
# my own helper method to generate a unique filename
filename = createUniqueFilename()
f = open('/var/files/' + filename, 'w')
f.write(filecontent)
f.close()


Every time a new source file has been created it needs to be copied or 
moved from machine #01 to machine #02.
Are there Python modules which help me doing this job? Any examples how 
to do that would be very helpful.

Kind regards and many thanks in advance,
Nico
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to copy a file from one machine to another machine

2005-09-21 Thread Nico Grubert
 This isn't really a Python question, as this problem would exist 
 irrespective of the language you are using.
 
 One possibility would be to run Samba (www.smaba.org) on the Linux 
 machine so it offered a share to the Windows machine. Then you could 
 just write to a UNC path (\\server\path\to\file) from Windows and have 
 the file appear on the Linux machine.
 
 Another way would be to use CIFS client on Linux to access the share 
 from the Windows machine.
 
 There are many other file sharing solutions, and you can of course also 
 consider using FTP to send the file to the Linux server.

Hello Steve,

Samba is already installed and configured on the Linux machine. Can I 
just use file=open(path_to_my_windows_share,'w') in Python to mount 
the windows share and create the file?
By the way, your book Python Web Programming is one of the best python 
books I have read! Really good work!

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


Remove HTML tags (except anchor tag) from a string using regular expressions

2005-02-01 Thread Nico Grubert
Hello,
I want to remove all html tags from a string content except a 
...xxx/a.

My script reads like this:
###
import re
content = re.sub('([^!]([^]|\n)*)', '', content)
###
It works fine. It removes all html tags from content.
Unfortunately, this also removes  a ...xxx/a occurancies.
Any idea, how to modify this to remove all html tags except a ...xxx/a?
Thanks in advance,
Nico
--
http://mail.python.org/mailman/listinfo/python-list