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 good...@python.org # Copyright: This module has been placed in the

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: 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 allow for some quoting, e.g. Guido van Rossum should

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 to do it more elegantly? I know I could use a while

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 know I could use a while loop but I don't like it. Many thanks

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 jarau...@igpm.rwth-aachen.de 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 know I could use a while loop

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 ... # how to avoid / simplify the following function def

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 jarau...@igpm.rwth-aachen.de 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 can't believe

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,

__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

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 something

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 ***

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 names, and

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

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 jarau...@igpm.rwth-aachen.de 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

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 arrays to Python. Guido's time

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 --

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 Possibilities+= 1

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 jarau...@igpm.rwth-aachen.de 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 might be faster. How does

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 jarau...@igpm.rwth-aachen.de wrote: I've tried the following version def find_good_cell() : Best= None minPoss= 10 for r,c in Grid : if Grid[(r,c)] 0 : continue Sorry, I think

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 are you timing the calls? I've put

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 from

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 last):

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

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,

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 jarau...@skynet.be wrote: Hi, I'm trying to port a class to Python3.3 which contains class Foo : def to_binary(self, *varargs, **keys

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= ... args= ... # Add function header code = 'def to_binary

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 : def to_binary(self, *varargs, **keys): self.to_binary

[issue17413] format_exception() breaks on exception tuples from trace function

2013-03-14 Thread Helmut Jarausch
Helmut Jarausch added the comment: The problem is caused by the new format_exception in Python's traceback.py file. It reads def format_exception(etype, value, tb, limit=None, chain=True): list = [] if chain: values = _iter_chain(value, tb) else: values = [(value, tb

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

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 jarau...@skynet.be wrote: 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

[issue17266] Idle + tcl 8.6.0 Can't convert '_tkinter.Tcl_Obj' object to str implicitly

2013-02-21 Thread Helmut Jarausch
New submission from Helmut Jarausch: I have tcl/tk 8.6.0 installed here. Both Python versions below are build from source. I'm using LANG=en_US.iso88591 here if that matters. When opening a file in Idle with python-3.3.1 revision: c08bcf5302ec or python-3.4.0a0 (default:3a110a506d35) (HG

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=

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 transfer changes in that local copy to the locals of my

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

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' any lines to it. If the mbox file contains a white line

[issue16811] email.message.Message flatten dies of list index out of range

2012-12-29 Thread Helmut Jarausch
New submission from Helmut Jarausch: The following code triggers the bug: #!/usr/bin/python3.3 #-*- coding: latin1 -*- from email.message import Message from email import policy from email.parser import FeedParser Parser= FeedParser(policy=policy.SMTP) Parser.feed('From jarau...@igpm.rwth

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=

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 module root.tk_setPalette(background =

[issue16541] tk_setPalette doesn't accept keyword parameters

2012-11-23 Thread Helmut Jarausch
New submission from Helmut Jarausch: import tkinter as Tk root= Tk.Tk() root.tk_setPalette(background = 'AntiqueWhite1', foreground = 'blue') but python-3.3:0+ (3.3:27cb1a3d57c8+) gives Traceback (most recent call last): File Matr_Select.py, line 174, in module root.tk_setPalette

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: 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') gives the error TypeError: coercing to str: need bytes, bytearray or buffer

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 jarau...@igpm.rwth-aachen.de 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 heavily-used mature

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: 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 work A=1 B=2 Code=compile('A=7','','exec') exec(Code

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 =

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! Helmut. --

[issue15763] email non-ASCII characters in TO or FROM field doesn't work

2012-08-22 Thread Helmut Jarausch
New submission from Helmut Jarausch: Trying to generate an email with Latin-1 characters in the TO or FROM field either produces an exception or produces strange values in the generated email: Using Python 3.2.3+ (3.2:481f5d9ef577+, Aug 8 2012, 10:00:28) #!/usr/bin/python3 #-*- coding

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=

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 wrong with the following script? Many thanks for a hint, Helmut

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 foo

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 jarau...@skynet.be wrote: Hi, for tracing purposes I have added some print outs like print('+++ before calling foo',file=sys.stderr) x=foo(..) print('--- after calling foo', Sorry, this is a cut'n

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

2012-08-07 Thread Helmut Jarausch
? Many thanks for a hint, Helmut Jarausch RWTH Aachen University Germany -- http://mail.python.org/mailman/listinfo/python-list

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' name,

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 =

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

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 locale.getdefaultlocale()[1] returns

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'] How

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're not supposed to. It must remain 'ascii

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)

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,

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 partition python -v import site fails

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

Re: HTTP server + SQLite?

2010-05-03 Thread Helmut Jarausch
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

Re: Teaching Programming

2010-05-03 Thread Helmut Jarausch
in http://www.linuxjournal.com/article/3882 Please have a look at it, Helmut. (I'm teaching programming for more than 15 years) -- 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 fuer

Re: how to debug python application crashed occasionally

2010-04-26 Thread Helmut Jarausch
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

Re: Operations on sparse matrices

2010-04-21 Thread Helmut Jarausch
, 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 Aachen, Germany -- http

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

2010-02-14 Thread Helmut Jarausch
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
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

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

2010-01-21 Thread Helmut Jarausch
() 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 lookaheads

Re: python regex negative lookahead assertions problems

2009-11-22 Thread Helmut Jarausch
, 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('(ok|warning)') : call_skip Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen

pygtk - icons?

2009-11-18 Thread Helmut Jarausch
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 Numerische Mathematik RWTH - Aachen University D 52056

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

2009-10-12 Thread Helmut Jarausch
() 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 52056 Aachen, Germany -- http://mail.python.org/mailman

Syntax question

2009-10-10 Thread Helmut Jarausch
() 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 Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch jarausch at 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 Changed Date: 2009-10

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch jarausch at 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 -mtune=native -msse2 -pipe

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 Numerische

convert Dbase (.dbf) files to SQLite databases

2009-07-15 Thread Helmut Jarausch
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 doesn't work. What do you

email scanning for X-Spam-Score

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

variable length tuple assignment

2009-02-25 Thread Helmut Jarausch
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

PyCrypto AES MODE_CBC - How to?

2009-02-25 Thread Helmut Jarausch
= '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 Numerische Mathematik RWTH - Aachen University D

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) # crypt = AES.new(PWD, AES.MODE_ECB

subprocess.Popen - file like object from stdout=PIPE

2009-02-04 Thread Helmut Jarausch
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. Many thanks for a hint, Helmut. -- Helmut

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 jarau...@skynet.be 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 is a string

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

2009-02-04 Thread Helmut Jarausch
Clovis Fabricio wrote: 2009/2/4 Helmut Jarausch jarau...@skynet.be: 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 lines. I'd

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

2009-02-04 Thread Helmut Jarausch
Clovis Fabricio wrote: 2009/2/4 Helmut Jarausch jarau...@skynet.be: 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

python3.0 - any hope it will get faster?

2008-12-09 Thread Helmut Jarausch
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 list of names, say

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'] and I like to generate abbreviation _A

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). Maybe

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

2008-12-01 Thread Helmut Jarausch
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

double import protection - how to ?

2008-11-29 Thread Helmut Jarausch
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: 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 default

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 work? Would it happen to be supported

Re: python3 - the hardest hello world ever ?

2008-10-16 Thread Helmut Jarausch
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-16 Thread Helmut Jarausch
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, Germany -- http

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' or to switch

  1   2   >