Python3 - temporarily change the file encoding

2014-03-21 Thread Helmut Jarausch
Hi, my locale is en_US.iso88591 But now I'd like to process a restructuredtext file which is encoded in utf-8. rst2html has #!/usr/bin/python3.3 # $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $ # Author: David Goodger # Copyright: This module has been placed in the public domain. """ A

Re: smart splitting - how to

2013-12-13 Thread Helmut Jarausch
On Fri, 13 Dec 2013 11:39:57 +, Chris Angelico and Robert Kern wrote: > On 2013-12-13 11:28, Helmut Jarausch wrote: >> Hi, >> >> I'd like to read several strings by using 'input'. >> These strings are separated by white space but I'd like to a

smart splitting - how to

2013-12-13 Thread Helmut Jarausch
Hi, I'd like to read several strings by using 'input'. These strings are separated by white space but I'd like to allow for some quoting, e.g. "Guido van" Rossum should be split into 2 strings only Now, a simple split doesn't work since it splits the quoted text as well. Is there a simple way

Re: extracting a heapq in a for loop - there must be more elegant solution

2013-12-04 Thread Helmut Jarausch
On Wed, 04 Dec 2013 08:13:03 +1100, Cameron Simpson wrote: > On 03Dec2013 12:18, Helmut Jarausch wrote: >> I'd like to extracted elements from a heapq in a for loop. >> I feel my solution below is much too complicated. >> How to do it more elegantly? > > I ca

Re: extracting a heapq in a for loop - there must be more elegant solution

2013-12-04 Thread Helmut Jarausch
On Tue, 03 Dec 2013 15:56:11 +0200, Jussi Piitulainen wrote: > Helmut Jarausch writes: > ... >> I know I could use a while loop but I don't like it. > ... >> from heapq import heappush, heappop >> # heappop raises IndexError if heap is empty > ... >>

Re: extracting a heapq in a for loop - there must be more elegant solution

2013-12-04 Thread Helmut Jarausch
On Tue, 03 Dec 2013 13:06:05 +, Duncan Booth wrote: > Helmut Jarausch wrote: > >> Hi, >> >> I'd like to extracted elements from a heapq in a for loop. >> I feel my solution below is much too complicated. >> How to do it more elegantly? >> I

Re: extracting a heapq in a for loop - there must be more elegant solution

2013-12-04 Thread Helmut Jarausch
On Tue, 03 Dec 2013 04:40:26 -0800, rusi wrote: > On Tuesday, December 3, 2013 5:48:59 PM UTC+5:30, Helmut Jarausch wrote: >> Hi, >> >> I'd like to extracted elements from a heapq in a for loop. >> I feel my solution below is much too complicated. >> How

Re: extracting a heapq in a for loop - there must be more elegant solution

2013-12-04 Thread Helmut Jarausch
On Tue, 03 Dec 2013 13:38:58 +0100, Peter Otten wrote: > Helmut Jarausch wrote: > >> Hi, >> >> I'd like to extracted elements from a heapq in a for loop. >> I feel my solution below is much too complicated. >> How to do it more elegantly? >> I kn

extracting a heapq in a for loop - there must be more elegant solution

2013-12-03 Thread Helmut Jarausch
Hi, I'd like to extracted elements from a heapq in a for loop. I feel my solution below is much too complicated. How to do it more elegantly? I know I could use a while loop but I don't like it. Many thanks for some lessons in Python. Here is my clumsy solution from heapq import heappush, heap

__iadd__ for a subclass of array - howto

2013-08-05 Thread Helmut Jarausch
Hi, I'd like to subclass array.array and implement operators like __iadd__ How can this be accomplished. I'tried from array import array class Vec(array) : def __new__(cls,Vinit) : return array.__new__(cls,'d',Vinit) def __init__(self,*args) : self.N = len(self) def __str__(self

Re: How to make this faster

2013-07-06 Thread Helmut Jarausch
On Sat, 06 Jul 2013 03:05:30 +, Steven D'Aprano wrote: > That doesn't explain how you time it, only that you have a loop executing > 100 times. Are you using time.time, or time.clock? (I trust you're not > measuring times by hand with a stop watch.) > > I expect you're probably doing someth

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 17:25:54 +0100, MRAB wrote: > For comparison, here's my solution: Your solution is very fast, indeed. It takes 0.04 seconds (mean of 1000 runs) restoring "grid" in between. But that's a different algorithm which is IMHO more difficult to understand. Many thanks, Helmut > >

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:50:41 +, Steven D'Aprano wrote: > On Fri, 05 Jul 2013 16:07:03 +, Helmut Jarausch wrote: > >> The solution above take 0.79 seconds (mean of 100 calls) while the >> following version take 1.05 seconds (mean of 100 calls): > > 1) How ar

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:38:43 +0100, Oscar Benjamin wrote: > On 5 July 2013 16:17, Helmut Jarausch wrote: >> >> I've tried the following version >> >> def find_good_cell() : >> Best= None >> minPoss= 10 >> for r,c in Grid : >> i

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:18:41 +0100, Fábio Santos wrote: > On 5 Jul 2013 15:59, "Helmut Jarausch" wrote: >> >> On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: >> May I suggest you avoid range and use enumerate(the_array) instead? It >> migh

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 15:45:25 +0100, Oscar Benjamin wrote: > Presumably then you're now down to the innermost loop as a bottle-neck: > > Possibilities= 0 > for d in range(1,10) : > if Row_Digits[r,d] or Col_Digits[c,d] or Sqr_Digits[Sq_No,d] : > continue > Possibilitie

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: May I suggest you avoid range and use enumerate(the_array) instead? It might be faster. How does this work? Given Grid= [[0 for j in range(9)] for i in range(9)] for (r,c,val) in (Grid) : Helmut -- http://mail.python.org/mailman/lis

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 12:02:21 +, Steven D'Aprano wrote: > On Fri, 05 Jul 2013 10:53:35 +, Helmut Jarausch wrote: > >> Since I don't do any numerical stuff with the arrays, Numpy doesn't seem >> to be a good choice. I think this is an argument to add real

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 14:41:23 +0100, Oscar Benjamin wrote: > On 5 July 2013 11:53, Helmut Jarausch wrote: >> I even tried to use dictionaries instead of Numpy arrays. This version is a >> bit >> slower then the lists of lists version (7.2 seconds instead of 6 second) but &g

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 11:13:33 +0100, Oscar Benjamin wrote: > My one comment is that you're not really making the most out of numpy > arrays. Numpy's ndarrays are efficient when each line of Python code > is triggering a large number of numerical computations performed over > the array. Because of t

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 10:38:35 +0100, Fábio Santos wrote: > [Skipping to bottleneck] > >> def find_good_cell() : > > In this function you are accessing global variables a lot of times. Since > accessing globals takes much more time than accessing locals, I advise you > to assign them to local name

How to make this faster

2013-07-05 Thread Helmut Jarausch
Hi, I have coded a simple algorithm to solve a Sudoku (probably not the first one). Unfortunately, it takes 13 seconds for a difficult problem which is more than 75 times slower than the same algorithm coded in C++. Is this to be expected or could I have made my Python version faster *** without

Re: python3 import idlelib.PyShell fails

2013-06-30 Thread Helmut Jarausch
On Sun, 30 Jun 2013 13:20:24 +0200, Peter Otten wrote: Thanks a lot! Helmut. -- http://mail.python.org/mailman/listinfo/python-list

python3 import idlelib.PyShell fails

2013-06-30 Thread Helmut Jarausch
Hi, I have a strange error. When I try import idlelib.PyShell from Python3.3 it fails with Python 3.3.2+ (3.3:68ff68f9a0d5+, Jun 30 2013, 12:59:15) [GCC 4.7.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import idlelib.PyShell Traceback (most recent call

Re: new.instancemethod - how to port to Python3

2013-04-07 Thread Helmut Jarausch
On Sun, 07 Apr 2013 11:07:07 +, Steven D'Aprano wrote: > On Sun, 07 Apr 2013 10:54:46 +, Helmut Jarausch wrote: > >> class Foo : >> >> def to_binary(self, *varargs, **keys): >> >>code= ... >>

Re: new.instancemethod - how to port to Python3

2013-04-07 Thread Helmut Jarausch
On Sun, 07 Apr 2013 10:52:11 +, Steven D'Aprano wrote: > On Sun, 07 Apr 2013 09:50:35 +, Helmut Jarausch wrote: > >> Hi, >> >> I'm trying to port a class to Python3.3 which contains >> >> class Foo : >>

Re: new.instancemethod - how to port to Python3

2013-04-07 Thread Helmut Jarausch
On Sun, 07 Apr 2013 11:41:46 +0100, Arnaud Delobelle wrote: > On 7 April 2013 10:50, Helmut Jarausch wrote: >> Hi, >> >> I'm trying to port a class to Python3.3 which contains >> >> class Foo : >>

new.instancemethod - how to port to Python3

2013-04-07 Thread Helmut Jarausch
Hi, I'm trying to port a class to Python3.3 which contains class Foo : def to_binary(self, *varargs, **keys): self.to_binary = new.instancemethod(to_binary, self, self.__class__) # Finally call it manually return apply(self.to_binary, varargs, key

Re: raw format string in string format method?

2013-02-28 Thread Helmut Jarausch
On Fri, 01 Mar 2013 01:22:48 +1100, Chris Angelico wrote: > On Fri, Mar 1, 2013 at 1:11 AM, Helmut Jarausch > wrote: >> Hi, >> >> I'd like to print a string with the string format method which uses >> {0}, ... >> >> Unfortunately, the string co

raw format string in string format method?

2013-02-28 Thread Helmut Jarausch
Hi, I'd like to print a string with the string format method which uses {0}, ... Unfortunately, the string contains TeX commands which use lots of braces. Therefore I would have to double all these braces just for the format method which makes the string hardly readable. Is there anything like a

Re: Python3 exec locals - this must be a FAQ

2013-02-12 Thread Helmut Jarausch
On Tue, 12 Feb 2013 08:27:41 -0500, Dave Angel wrote: > On 02/12/2013 06:46 AM, Helmut Jarausch wrote: >> Hi, >> >> I've tried but didn't find an answer on the net. >> >> The exec function in Python modifies a copy of locals() only. >> How can I

Python3 exec locals - this must be a FAQ

2013-02-12 Thread Helmut Jarausch
Hi, I've tried but didn't find an answer on the net. The exec function in Python modifies a copy of locals() only. How can I transfer changes in that local copy to the locals of my function ** without ** knowing the names of these variables. E.g. I have a lot of local names. Doing _locals= l

re: ignore case only for a part of the regex?

2012-12-30 Thread Helmut Jarausch
Hi, is there a means to specify that 'ignore-case' should only apply to a part of a regex? E.g. the regex should match Msg-id:, Msg-Id, ... but not msg-id: and so on. I've tried the pattern r'^Msg-(?:(?i)id):' but (?i) makes the whole pattern ignoring case. In my simple case I could say r'M

Re: email.message.Message - as_string fails

2012-12-29 Thread Helmut Jarausch
On Fri, 28 Dec 2012 20:57:46 -0500, Terry Reedy wrote: > On 12/28/2012 7:22 AM, Helmut Jarausch wrote: >> Hi, >> >> I'm trying to filter an mbox file by removing some messages. >> For that I use Parser= FeedParser(policy=policy.SMTP) >> and 'feed'

email.message.Message - as_string fails

2012-12-28 Thread Helmut Jarausch
Hi, I'm trying to filter an mbox file by removing some messages. For that I use Parser= FeedParser(policy=policy.SMTP) and 'feed' any lines to it. If the mbox file contains a white line followed by '^From ', I do Msg= Parser.close() (lateron I delete the Parser and create a new one by Parser= F

python3.3 - tk_setPalette bug?

2012-11-23 Thread Helmut Jarausch
Hi, AFAIK, this should work: import tkinter as Tk root= Tk.Tk() root.tk_setPalette(background = 'AntiqueWhite1', foreground = 'blue') but python-3.3:0e4574595674+ gives Traceback (most recent call last): File "Matr_Select.py", line 174, in root.tk_setPalette(background = 'AntiqueWhite1',

Re: Python3.3 str() bug?

2012-11-09 Thread Helmut Jarausch
On Fri, 09 Nov 2012 23:22:04 +1100, Chris Angelico wrote: > On Fri, Nov 9, 2012 at 10:08 PM, Helmut Jarausch > wrote: >> For me it's not funny, at all. > > His description "funny" was in reference to the fact that you > described this as a bug. This is a hea

Re: Python3.3 str() bug?

2012-11-09 Thread Helmut Jarausch
On Fri, 09 Nov 2012 10:37:11 +0100, Stefan Behnel wrote: > Helmut Jarausch, 09.11.2012 10:18: >> probably I'm missing something. >> >> Using str(Arg) works just fine if Arg is a list. >> But >> str([],encoding='latin-1') >> >&g

Python3.3 str() bug?

2012-11-09 Thread Helmut Jarausch
Hi, probably I'm missing something. Using str(Arg) works just fine if Arg is a list. But str([],encoding='latin-1') gives the error TypeError: coercing to str: need bytes, bytearray or buffer-like object, list found If this isn't a bug how can I use str(Arg,encoding='latin-1')

Re: exec with partial globals

2012-10-30 Thread Helmut Jarausch
On Tue, 30 Oct 2012 08:33:38 -0400, Dave Angel wrote: > On 10/30/2012 08:00 AM, Helmut Jarausch wrote: >> Hi, >> >> I'd like to give the user the ability to enter code which may only rebind >> a given set of names but not all ones. >> This does NOT w

exec with partial globals

2012-10-30 Thread Helmut Jarausch
Hi, I'd like to give the user the ability to enter code which may only rebind a given set of names but not all ones. This does NOT work A=1 B=2 Code=compile('A=7','','exec') exec(Code,{'A':0}) print("I've got A={}".format(A)) # prints 1 How can 'filter' the gobal namespace such that modifying 'A

Re: Python3.3 email policy date field

2012-08-23 Thread Helmut Jarausch
On Thu, 23 Aug 2012 12:36:01 +0100, MRAB wrote: > From what I've tried, it looks like the date can't be a string: > > >>> m['Date'] = datetime.datetime.utcnow() > >>> m['Date'] > 'Thu, 23 Aug 2012 11:33:20 -' Many thanks - it's even easier! Waiting for Python 3.3 to become standard! Helm

Python3.3 email policy date field

2012-08-23 Thread Helmut Jarausch
Hi, in response to a bug report I got the follow helpful comments from R. David Murray. Many thanks to him. (Unfortunately, I don't know his email, so I can write him directly) To generate an email (with non-ascii letters) R. David Murray wrote: >>> But even better, so will this: >>> m = Mes

Re: email with a non-ascii charset in Python3 ?

2012-08-15 Thread Helmut Jarausch
On Wed, 15 Aug 2012 14:48:40 +0200, Christian Heimes wrote: > Am 15.08.2012 14:16, schrieb Helmut Jarausch: >> Hi, >> >> I'm sorry to ask such a FAQ but still I couldn't find an answer - >> neither in the docs nor the web. >> >> What's wro

email with a non-ascii charset in Python3 ?

2012-08-15 Thread Helmut Jarausch
Hi, I'm sorry to ask such a FAQ but still I couldn't find an answer - neither in the docs nor the web. What's wrong with the following script? Many thanks for a hint, Helmut. #!/usr/bin/python3 #_*_ coding: latin1 _*_ import smtplib from email.message import Message import datetime msg= Mess

Re: print(....,file=sys.stderr) buffered?

2012-08-13 Thread Helmut Jarausch
On Mon, 13 Aug 2012 15:43:31 +, Grant Edwards wrote: > On 2012-08-13, Helmut Jarausch wrote: >> Hi, >> >> for tracing purposes I have added some print outs like >> >> print('+++ before calling foo',file=sys.stderr) >> x=foo(..) >> print(

print(....,file=sys.stderr) buffered?

2012-08-13 Thread Helmut Jarausch
Hi, for tracing purposes I have added some print outs like print('+++ before calling foo',file=sys.stderr) x=foo(..) print('--- after calling foo', and within 'foo' print('>>> entering foo ...',file=sys.stderr) Now, when executing this, I always get +++ before calling foo --- after calling f

Re: Procedure to request adding a module to the standard library - or initiating a vote on it

2012-08-07 Thread Helmut Jarausch
On Tue, 07 Aug 2012 13:15:29 +0200, Peter Otten wrote: > I don't think that will help. From PEP 408: > > """ > As part of the same announcement, Guido explicitly accepted Matthew > Barnett's 'regex' module [4] as a provisional addition to the standard > library for Python 3.3 (using the 'regex' n

Procedure to request adding a module to the standard library - or initiating a vote on it

2012-08-07 Thread Helmut Jarausch
ator" for Python. Should I try to contact him personally? Many thanks for a hint, Helmut Jarausch RWTH Aachen University Germany -- http://mail.python.org/mailman/listinfo/python-list

numpy.genfromtxt with Python3 - howto

2012-04-06 Thread Helmut Jarausch
Hi I have a machine with a non-UTF8 local. I can't figure out how to make numpy.genfromtxt work I pipe some ascii data into the following script but get this bytes to str hell. Many thanks for a hint, Helmut. #!/usr/bin/python3 import numpy as np import io import sys inpstream = io.open(sys.s

Re: getdefaultencoding - how to change this?

2011-01-20 Thread Helmut Jarausch
On Thu, 20 Jan 2011 10:46:37 -0600, Robert Kern wrote: > On 1/20/11 8:31 AM, Helmut Jarausch wrote: >> Hi, >> I've searched the net but didn't find the information I need. Using >> Python-2.7.1, I know, I can't modify defaultencoding at run time. > > You

printing a list with non-ascii strings

2011-01-20 Thread Helmut Jarausch
Hi, I don't understand Python's behaviour when printing a list. The following example uses 2 German non-ascii characters. #!/usr/bin/python # _*_ coding: latin1 _*_ L=["abc","süß","def"] print L[1],L The output of L[1] is correct, while the output of L shows up as ['abc', 's\xfc\xdf', 'def'] H

Re: getdefaultencoding - how to change this?

2011-01-20 Thread Helmut Jarausch
On Thu, 20 Jan 2011 14:31:09 +, Helmut Jarausch wrote: > Hi, > I've searched the net but didn't find the information I need. Using > Python-2.7.1, I know, I can't modify defaultencoding at run time. Python > even ignores > export PYTHONIOENCODING=ISO8859-1 &g

getdefaultencoding - how to change this?

2011-01-20 Thread Helmut Jarausch
Hi, I've searched the net but didn't find the information I need. Using Python-2.7.1, I know, I can't modify defaultencoding at run time. Python even ignores export PYTHONIOENCODING=ISO8859-1 locale.getdefaultlocale()[1] returns 'ISO8859-1' still sys.stdout is using the ascii codec. How can I r

import site fails - Please Help

2010-11-15 Thread Helmut Jarausch
Hi, I'm completely puzzled and I hope someone can shed some light on it. After cloning a running system, booting the new machine from a rescue CD, chroot to the new root partition, I get the following strange error from python upon startup python -v > import site failed st= os.stat(path) sta

Re: importing site fails - why?

2010-11-12 Thread Helmut Jarausch
On Fri, 12 Nov 2010 19:42:46 +0100, Stefan Sonnenberg-Carstens wrote: > Am 12.11.2010 19:32, schrieb Helmut Jarausch: >> Hi, >> >> as often before, I've cloned a working system (GenToo) onto another >> machine. There, from a livecd and chroot to the cloned root par

importing site fails - why?

2010-11-12 Thread Helmut Jarausch
Hi, as often before, I've cloned a working system (GenToo) onto another machine. There, from a livecd and chroot to the cloned root partition python -v import site fails with the following error Python 2.6.6 (r266:84292, Oct 13 2010, 09:06:24) [GCC 4.4.4] on linux2 Type "help", "copyright", "cr

Re: fast regex

2010-05-07 Thread Helmut Jarausch
On 05/06/10 16:52, james_027 wrote: > hi, > > I was working with regex on a very large text, really large but I have > time constrained. Does python has any other regex library or string > manipulation library that works really fast? Have a look at http://www.egenix.com/products/python/mxBase/mx

Re: Teaching Programming

2010-05-03 Thread Helmut Jarausch
f nearly each statement in Perl, that it is hard to understand and debug unless you're using it several hours a day (each day). What convinced me is clearly written in http://www.linuxjournal.com/article/3882 Please have a look at it, Helmut. (I'm teaching programming for more than 15

Re: HTTP server + SQLite?

2010-05-03 Thread Helmut Jarausch
application. This > is just for a proof-of-concept, so it doesn't need to be > shipping-quality. > You might have a look at http://www.karrigell.fr/doc/ Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

External Hashing [was Re: matching strings in a large set of strings]

2010-04-30 Thread Helmut Jarausch
I think one could apply an external hashing technique which would require only very few disk accesses per lookup. Unfortunately, I'm now aware of an implementation in Python. Does anybody know about a Python implementation of external hashing? Thanks, Helmut. -- Helmut Jarausch Lehrstuhl

Re: how to debug python application crashed occasionally

2010-04-26 Thread Helmut Jarausch
s yet. >> >> I will be really appreciated if somebody can help me about how to >> debug the python crashes. >> For me, it sounds like a hardware problem. Have run memory tests like memtest86+ and/or memtester? You could try a more recent version of Python like 2.6.5 and see if you get the same sort of errors. Try to run your application on a different machine if possible, to exclude hardware errors. Have you rebuild all Python packages you're using and which use an extension in C / C++ ? after upgrading? I hope this helps a bit, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: Operations on sparse matrices

2010-04-21 Thread Helmut Jarausch
rse matrix. Note, in nearly all cases the inverse of a sparse matrix is a full matrix. Instead of inverting a matrix solve a linear system with that matrix. What do you need the inverse for? Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aach

Re: How to solve an LCP (linear complementarity problem) in python ?

2010-02-14 Thread Helmut Jarausch
2d contact forces in a rigid body > simulation. Sorry, I can't help you except pointing you to the Complementarity Problem Net http://www.cs.wisc.edu/cpnet/ -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: Repost: Read a running process output

2010-02-05 Thread Helmut Jarausch
gt;> p1=Popen(['/usr/sunvts/bin/64/vtsk','-d'],stdout=PIPE) >>>> while 1: > ... a=p1.stdout.readline() > ... print a > ... I've tried #!/usr/bin/python import subprocess p1= subprocess.Popen(['/bin/ls','/LOCAL/'],stdout=subprocess.PIPE) for line in p1.stdout : print ">>>",line which works just fine. Are you sure, your /usr/sunvts/bin/64/vtsk writes a newline character (readline is waiting for that)? Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to convert sequence of bytes to long integer

2010-01-21 Thread Helmut Jarausch
n Python 3.2a0) since hashlib.md5(key).digest() returns a byte string which has no .encode method. Just my 5 cents, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: python regex "negative lookahead assertions" problems

2009-11-23 Thread Helmut Jarausch
On 11/22/09 16:05, Helmut Jarausch wrote: On 11/22/09 14:58, Jelle Smet wrote: Hi List, I'm trying to match lines in python using the re module. The end goal is to have a regex which enables me to skip lines which have ok and warning in it. But for some reason I can't get negative

Re: python regex "negative lookahead assertions" problems

2009-11-22 Thread Helmut Jarausch
tive lookahead and warning is in the string. '.*' eats all of line. Now, when at end of line, there is no 'warning' anymore, so it matches. What are you trying to achieve? If you just want to single out lines with 'ok' or warning in it, why not just if re.search(&

pygtk - icons?

2009-11-18 Thread Helmut Jarausch
perhaps you need to install it. You can get a copy from: http://icon-theme.freedesktop.org/releases On my Gentoo system lots of packages have placed icons under /usr/share/icons/hicolor So, what am I missing. Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerisch

Python-3.2 (SVN) bug [was syntax question]

2009-10-12 Thread Helmut Jarausch
group(*choices) + '?' with: TypeError: group() argument after ** must be a mapping, not tuple Meanwhile I could narrow this down to the --with-tsc configure option. Without it, it builds just fine. Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Changed Date: 2009-10-10) I can't reproduce your failure. What are the exact commands you are using? CFLAGS='-O3 -mt

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: Hi, I'm trying to build the recent Python-3.2a (SVN). It fails in Lib/tokenize.py (line 87) How are you invoking it? As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Chan

Syntax question

2009-10-10 Thread Helmut Jarausch
group(*choices) + '?' with: TypeError: group() argument after ** must be a mapping, not tuple I'm afraid I don't understand this error message. BTW I'm using python-2.6.3 on the machine where I try to install 3.2a Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer

How to search this newsgroup by a python script.

2009-07-16 Thread Helmut Jarausch
Hi, I haven't found anything with Google's group search, so let me ask it (again?). How can I search this newsgroup from within a Python script. (Perhaps by searching Google Groups or Gmane by some Python code.) Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer

convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Helmut Jarausch
s for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

email scanning for X-Spam-Score

2009-05-25 Thread Helmut Jarausch
Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: email scanning for X-Spam-Score

2009-05-25 Thread Helmut Jarausch
Peter Otten wrote: Helmut Jarausch wrote: my emails received from our mailing system contain a field like X-Spam-Score: -2.2 Given the full email message in 'msg' I've tried mailmsg = email.message_from_string(msg) SPAM_CORE = mailmsg['X-Spam-Score'] but it do

Re: PyCrypto AES MODE_CBC - How to?

2009-02-25 Thread Helmut Jarausch
Helmut Jarausch wrote: Hi, I've just tried to write a simple example using PyCrypto's AES (CBC mode) #!/usr/bin/python from Crypto.Cipher import AES PWD='abcdefghijklmnop' Initial16bytes='0123456789ABCDEF' crypt = AES.new(PWD, AES.MODE_CBC,Initial16bytes) # cry

PyCrypto AES MODE_CBC - How to?

2009-02-25 Thread Helmut Jarausch
ES.new(PWD, AES.MODE_ECB) txt = 'ea523a664dabaa4476d31226a1e3bab0' c = crypt.encrypt(txt) txt_plain=crypt.decrypt(c) print txt_plain Unfortunately, txt_plain differs from txt - why? (Using MODE_ECB does work however) What am I missing? Many thanks for a hint, Helmut Jarausch Lehrstuhl fuer Numerisc

variable length tuple assignment

2009-02-25 Thread Helmut Jarausch
s there some shorthand for this? Many thanks for a hint, Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Helmut Jarausch
Clovis Fabricio wrote: 2009/2/4 Helmut Jarausch : EQ.stdout is the filelike object you're looking for. communicate() grabs entire output at once so don't use it. Thanks a lot, I haven't found that in the official documentation. Helmut. That would be a documentation bug. Fortun

Re: subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Helmut Jarausch
Clovis Fabricio wrote: 2009/2/4 Helmut Jarausch : using e.g. import subprocess Package='app-arch/lzma-utils' EQ=subprocess.Popen(['/usr/bin/equery','depends',Package],stdout=subprocess.PIPE) EQ_output= EQ.communicate()[0] EQ_output is a string containing multiple

Re: subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Helmut Jarausch
Chris Rebert wrote: On Wed, Feb 4, 2009 at 1:22 AM, Helmut Jarausch wrote: Hi, using e.g. import subprocess Package='app-arch/lzma-utils' EQ=subprocess.Popen(['/usr/bin/equery','depends',Package],stdout=subprocess.PIPE) EQ_output= EQ.communicate()[0] EQ_output i

subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Helmut Jarausch
e.g. EQ_OUT so that I can loop over the lines of it like for line in EQ_OUT : ... I could use StringIO.StringIO applied to EQ_output but this reads all of the command's output into a big string first. On Unix/Linux a pipe is a file-like object after all, so how to get hold of it. Ma

python3.0 - any hope it will get faster?

2008-12-09 Thread Helmut Jarausch
ame war! I know computers get faster, we human beings don't (me, at least) -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it safe to modify the dict returned by vars() or locals()

2008-12-03 Thread Helmut Jarausch
Duncan Booth wrote: Helmut Jarausch <[EMAIL PROTECTED]> wrote: Chris Rebert wrote: On Mon, Dec 1, 2008 at 1:01 PM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: Hi, I am looking for an elegant way to solve the following problem: Within a function def Foo(**parms) I have a l

Re: Is it safe to modify the dict returned by vars() or locals()

2008-12-02 Thread Helmut Jarausch
Chris Rebert wrote: On Mon, Dec 1, 2008 at 1:01 PM, Helmut Jarausch <[EMAIL PROTECTED]> wrote: Hi, I am looking for an elegant way to solve the following problem: Within a function def Foo(**parms) I have a list of names, say VList=['A','B','C1'] an

Is it safe to modify the dict returned by vars() or locals()

2008-12-01 Thread Helmut Jarausch
parms) : for N in VList : if N in parms : vars()[N]= parms[N] else : vars()[N]= None Does this work, is it typical Python? Many thanks for a hint, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: double import protection - how to ?

2008-12-01 Thread Helmut Jarausch
Peter Otten wrote: Helmut Jarausch wrote: Peter Otten wrote: Helmut Jarausch wrote: Then it's a problem with a problem with a webserver written in Python (Karrigell-3.0) and probably related to multi-threading (the statements in my module get definitely executed more than once).

Re: double import protection - how to ?

2008-11-29 Thread Helmut Jarausch
Peter Otten wrote: Helmut Jarausch wrote: I have a module which gets imported at several different places not all of which are under my control. How can I achieve that all/some statements within that module get executed only at the very first import? What you describe is Python's de

double import protection - how to ?

2008-11-29 Thread Helmut Jarausch
st be executed only once, initializes another OS-thread (java in my case)) Many thanks for a hint, Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: python3 - the hardest hello world ever ?

2008-10-17 Thread Helmut Jarausch
Ross Ridge wrote: Helmut Jarausch <[EMAIL PROTECTED]> wrote: # but this ugly one (to be done for each output file) sys.stdout._encoding='latin1' Is this writable "_encoding" attribute, with a leading underscore (_), documented anywhere? Does it actually wo

Re: python3 - the hardest hello world ever ?

2008-10-16 Thread Helmut Jarausch
Paul Boddie wrote: On 16 Okt, 11:28, Helmut Jarausch <[EMAIL PROTECTED]> wrote: I meant setting the default encoding which is used by print (e.g.) when outputting the internal unicode string to a file. As far as I understood, currently I am fixed to setting either the 'locale&#x

Re: python3 - the hardest hello world ever ?

2008-10-16 Thread Helmut Jarausch
ither the 'locale' or to switch settings for each output file (by settting the _encoding property. I wished I could override the locale settings within a Python script. Thanks, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen,

Re: python3 - the hardest hello world ever ?

2008-10-16 Thread Helmut Jarausch
very beginning of a script. Why isn't that possible? Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch
Paul Boddie wrote: On 15 Okt, 12:08, Helmut Jarausch <[EMAIL PROTECTED]> wrote: What defines me as latin1-user? What does sys.stdout.encoding say? In Python 2.x, at least, that It says ansi_x3.4-1968 Where can I change this? attribute should reflect the capabilities of your envir

Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch
Brian Quinlan wrote: Hey Helmut, Did you try just: print("Hallo, Süßes Python") Yes, but that doesn't work here. Please see my reply to Martin's reply. Thanks, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aac

Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch
Ben Finney wrote: Helmut Jarausch <[EMAIL PROTECTED]> writes: I have to set an internal property (with leading underscore) for each output file I'm using - right? If you're referring to the source encoding declaration: No, underscores have no effect. The specific

Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch
odecs.ascii_encode(input, self.errors)[0] UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128) So my system seems to be an ASCII system? Thanks, Helmut -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D

python3 - the hardest hello world ever ?

2008-10-14 Thread Helmut Jarausch
ython") Thanks for any enlightening on that subject, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >