Re: User-defined exception: "global name 'TestRunError' is not defined"

2008-07-09 Thread Larry Bates
[EMAIL PROTECTED] wrote: I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other modules do not explicitly import TestRunError. TestRunError is raised in various

Re: You, spare time and SyntaxError

2008-07-09 Thread [EMAIL PROTECTED]
On 9 juil, 16:56, [EMAIL PROTECTED] wrote: > def ine(you): > yourself = "what?" > go = list("something"), list("anything") > be = "something" > please = be, yourself > yourself = "great" > for good in yourself: > if you is good: > good in you >

Re: Determining when a file has finished copying

2008-07-09 Thread Larry Bates
writeson wrote: Guys, Thanks for your replies, they are helpful. I should have included in my initial question that I don't have as much control over the program that writes (pgm-W) as I'd like. Otherwise, the write to a different filename and then rename solution would work great. There's no wa

Re: Relative Package Import

2008-07-09 Thread Kay Schluehr
On 8 Jul., 21:09, Peter Otten <[EMAIL PROTECTED]> wrote: > Robert Hancock wrote: > > mypackage/ > > __init__.py > > push/ > > __init__.py > > dest.py > > feed/ > >__init__py > > subject.py

Re: formatting list -> comma separated (slightly different)

2008-07-09 Thread Larry Bates
Michiel Overtoom wrote: Paul & Robert wrote... d = ["soep", "reeds", "ook"] print ', '.join(d) soep, reeds, ook I occasionally have a need for printing lists of items too, but in the form: "Butter, Cheese, Nuts and Bolts". The last separator is the word 'and' instead of the comma. The cleare

Re: formatting list -> comma separated (slightly different)

2008-07-09 Thread egbert
On Wed, Jul 09, 2008 at 10:25:33PM +0200, Michiel Overtoom wrote: > Formatting a sequence of items such that they are separated by > commas, except the last item, which is separated by the word 'and'. > > For example: > > Three friends have a dinner: Anne, Bob and Chris row = ["Anne","Bob","Chri

Re: formatting list -> comma separated (slightly different)

2008-07-09 Thread Duncan Booth
Michiel Overtoom <[EMAIL PROTECTED]> wrote: > I occasionally have a need for printing lists of items too, but in the > form: "Butter, Cheese, Nuts and Bolts". The last separator is the > word 'and' instead of the comma. The clearest I could come up with in > Python is below. I wonder if there is

Re: Determining when a file has finished copying

2008-07-09 Thread Daniel Mahoney
> Thanks for your replies, they are helpful. I should have included in > my initial question that I don't have as much control over the program > that writes (pgm-W) as I'd like. Otherwise, the write to a different > filename and then rename solution would work great. There's no way to > tell from

Retrieving BSTR * from a DLL

2008-07-09 Thread mzdude
I need to interface with a windows DLL that has the following signature extern "C" void Foo( BSTR in, BSTR *out ) Code so far >>> from ctypes import * >>> import comtypes >>> LPBSTR = POINTER(comtypes.BSTR) >>> >>> hdl = windll.MyDll.Foo >>> hdl.rettype = None >>> hdl.argtypes = [comtypes.BSTR,

Python equivalent of call/cc?

2008-07-09 Thread The Pythonista
Yesterday, I was hacking around a bit, trying to figure out how to implement the semantics of call/cc in Python. Specifically, I wanted to translate this Scheme code to equivalent Python: (define theContinuation #f) (define (test) (let ((i 0)) (call/cc (lambda (k) (set! theCont

Re: how to remove oldest files up to a limit efficiently

2008-07-09 Thread [EMAIL PROTECTED]
On Jul 9, 8:46 am, Dan Stromberg <[EMAIL PROTECTED]> wrote: > On Tue, 08 Jul 2008 15:18:23 -0700, [EMAIL PROTECTED] wrote: > > I need to mantain a filesystem where I'll keep only the most recently > > used (MRU) files; least recently used ones (LRU) have to be removed to > > leave space for newer o

Re: how to remove oldest files up to a limit efficiently

2008-07-09 Thread [EMAIL PROTECTED]
On Jul 9, 7:08 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Dan Stromberg wrote: > > On Tue, 08 Jul 2008 15:18:23 -0700, [EMAIL PROTECTED] wrote: > > >> I need to mantain a filesystem where I'll keep only the most recently > >> used (MRU) files; least recently used ones (LRU) have to be removed to

Re: Determining when a file has finished copying

2008-07-09 Thread Ethan Furman
writeson wrote: Guys, Thanks for your replies, they are helpful. I should have included in my initial question that I don't have as much control over the program that writes (pgm-W) as I'd like. Otherwise, the write to a different filename and then rename solution would work great. There's no wa

Terminate a python script from linux shell / bash script

2008-07-09 Thread Gros Bedo
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the f

RE: Freesoftware for auto/intelligent code completing in Python

2008-07-09 Thread Gros Bedo
Hello, Ali I totally support you, neither I couldn't find any really working code completion for python in a free software, and it's really a mess, at least on Linux. On Windows, there is PyScripter (http://pyscripter.googlepages.com/), but it is based on Delphi, and as such it's not portable.

Py_BuildValue for char **?

2008-07-09 Thread js
Hi, I'm writing a wrapper module of C API. To make a C struct data avaiable to Python, I need to map C struct into a PyObject. I'm thinking that I use a tuple or dict to represent the struct but a problem is one of the members of the struct is char **, which is not supported by Py_BuildValue. Is t

redirecting output of process to a file using subprocess.Popen()

2008-07-09 Thread rparimi
I am trying to redirect stderr of a process to a temporary file and then read back the contents of the file, all in the same python script. As a simple exercise, I launched /bin/ls but this doesn't work: #!/usr/bin/python import subprocess as proc import tempfile name = tempfile.NamedTemporaryFile

Python and decimal character entities over 128.

2008-07-09 Thread bsagert
Some web feeds use decimal character entities that seem to confuse Python (or me). For example, the string "doesn't" may be coded as "doesn’t" which should produce a right leaning apostrophe. Python hates decimal entities beyond 128 so it chokes unless you do something like string.encode('utf-8').

Manipulating bitsets in struct

2008-07-09 Thread Allen
I'm using Python to do some simple network programming, and found the struct module very useful for such things, but is there a way to easily manipulate bitsets such as a 16 bit word being split into 4 parts like 2 bits, 1 bit, 4 bits, and 9 bits? Perhaps something like: struct.pack('!h(2:1:4

Re: FOSS projects exhibiting clean/good OOP?

2008-07-09 Thread Daniel Fetchinson
>> I'm wondering whether anyone can offer suggestions on FOSS projects/ >> apps which exhibit solid OO principles, clean code, good inline >> documentation, and sound design principles? > > This is somewhat subjective... Some would say that Python's object > model is fundamentally broken and crappy

Re: Python equivalent of call/cc?

2008-07-09 Thread Larry Bates
The Pythonista wrote: Yesterday, I was hacking around a bit, trying to figure out how to implement the semantics of call/cc in Python. Specifically, I wanted to translate this Scheme code to equivalent Python: (define theContinuation #f) (define (test) (let ((i 0)) (call/cc

Re: Terminate a python script from linux shell / bash script

2008-07-09 Thread Larry Bates
Gros Bedo wrote: Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the backgro

Re: Manipulating bitsets in struct

2008-07-09 Thread Larry Bates
Allen wrote: I'm using Python to do some simple network programming, and found the struct module very useful for such things, but is there a way to easily manipulate bitsets such as a 16 bit word being split into 4 parts like 2 bits, 1 bit, 4 bits, and 9 bits? Perhaps something like: struct.

Re: Determining when a file has finished copying

2008-07-09 Thread keith
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ethan Furman wrote: > writeson wrote: >> Guys, >> >> Thanks for your replies, they are helpful. I should have included in >> my initial question that I don't have as much control over the program >> that writes (pgm-W) as I'd like. Otherwise, the write

Re: Determining when a file has finished copying

2008-07-09 Thread Larry Bates
keith wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ethan Furman wrote: writeson wrote: Guys, Thanks for your replies, they are helpful. I should have included in my initial question that I don't have as much control over the program that writes (pgm-W) as I'd like. Otherwise, the writ

Re: "in"consistency?

2008-07-09 Thread castironpi
On Jul 8, 2:25 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > castironpi wrote: > > Strings are not containers. > > Library Reference/Built-in Types/Sequence Types says > "Strings contain Unicode characters." > Perhaps you have a different notion of contain/container. > > I prefer 'collection' to 'co

Re: Determining when a file has finished copying

2008-07-09 Thread Cameron Simpson
On 09Jul2008 15:54, Ethan Furman <[EMAIL PROTECTED]> wrote: > The solution my team has used is to monitor the file size. If the file > has stopped growing for x amount of time (we use 45 seconds) the file is > done copying. Not elegant, but it works. If you know that files appear in sequence

TypeError, I know why but not how!?

2008-07-09 Thread ssecorp
Im looking into PvsNP: http://www.claymath.org/millennium/P_vs_NP/ so I thought I'd write the program just to get a feel for it. But I run into a problem. Why does it all the sudden return None? I mean I know why the program aborts but I dont understand why the None is generated all the sudden. H

Re: TypeError, I know why but not how!?

2008-07-09 Thread Robert Kern
ssecorp wrote: Im looking into PvsNP: http://www.claymath.org/millennium/P_vs_NP/ so I thought I'd write the program just to get a feel for it. But I run into a problem. Why does it all the sudden return None? I mean I know why the program aborts but I dont understand why the None is generated

Re: re.search much slower then grep on some regular expressions

2008-07-09 Thread John Machin
On Jul 9, 10:06 pm, Kris Kennaway <[EMAIL PROTECTED]> wrote: > John Machin wrote: > >> Hmm, unfortunately it's still orders of magnitude slower than grep in my > >> own application that involves matching lots of strings and regexps > >> against large files (I killed it after 400 seconds, compared t

Re: Dynamic HTML from Python Script

2008-07-09 Thread Ethan Furman
Dave Parker wrote: On Jun 11, 10:43 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: Those are not /server side/ refreshes... Correct. But we weren't discussing server side refreshes. We were discussing how to make the "browser refresh automatically in the server side": Two things:

Re: sage vs enthought for sci computing

2008-07-09 Thread Mike Hansen
On Jul 7, 3:35 pm, [EMAIL PROTECTED] wrote: > Hello, > I have recently become interested in using python for scientific > computing, and came across both sage and enthought. I am curious if > anyone can tell me what the differences are between the two, since > there seems to be a lot of overlap (fr

sort(cmp=func)

2008-07-09 Thread Tobiah
I have a list of objects that generate code. Some of them depend on others being listed first, to satisfy dependencies of others. I wrote a cmp function something like this: def dep_cmp(ob1, ob2): if ob1.name in ob2.deps: return -1 else:

Re: Python equivalent of call/cc?

2008-07-09 Thread Aahz
In article <[EMAIL PROTECTED]>, The Pythonista <[EMAIL PROTECTED]> wrote: > >Yesterday, I was hacking around a bit, trying to figure out how to >implement the semantics of call/cc in Python. Specifically, I wanted to >translate this Scheme code to equivalent Python: > > > >(define theContin

Re: Terminate a python script from linux shell / bash script

2008-07-09 Thread MRAB
On Jul 10, 1:25 am, Larry Bates <[EMAIL PROTECTED]> wrote: > Gros Bedo wrote: > > Hello :-) > > > I have a question about Python and Linux shell. I have a python program > > which is permanently resident in the end-user system. I'm currently > > producing a RPM package, and it works nicely. The p

Re: sort(cmp=func)

2008-07-09 Thread Daniel Fetchinson
> I have a list of objects that generate code. Some > of them depend on others being listed first, to > satisfy dependencies of others. > > I wrote a cmp function something like this: > > def dep_cmp(ob1, ob2): > > if ob1.name in ob2.deps: > return -1 > else: >

error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Jordan
I am trying to rewrite some C source code for a poker hand evaluator in Python. Putting aside all of the comments such as just using the C code, or using SWIG, etc. I have been having problems with my Python code not responding the same way as the C version. C verison: unsigned find_fast(unsign

Re: sort(cmp=func)

2008-07-09 Thread David Wahler
On Wed, Jul 9, 2008 at 10:58 PM, Daniel Fetchinson <[EMAIL PROTECTED]> wrote: > > > I have a list of objects that generate code. Some > > of them depend on others being listed first, to > > satisfy dependencies of others. > > > > I wrote a cmp function something like this: > > > > def dep_cmp(ob1,

Re: error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Dan Stromberg
On Wed, 09 Jul 2008 20:56:59 -0700, Jordan wrote: > I am trying to rewrite some C source code for a poker hand evaluator in > Python. Putting aside all of the comments such as just using the C > code, or using SWIG, etc. I have been having problems with my Python > code not responding the same w

Re: Py_BuildValue for char **?

2008-07-09 Thread Martin v. Löwis
> Is there any idiomatic way of mapping char ** to Python? My recommendation is to not use Py_BuildValue. Instead, use PyList_New, and then, in a loop, PyString_FromString/PyList_SetItem. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Jordan
I was actually just going through an example to show what was happening each step of the way and noticed the overflow!!! bah, stupid tricks tricks tricks!!! The problem is def the overflow, I notice that I start to get negative numbers in the C version, which makes me think that the & 0x t

python scalability

2008-07-09 Thread Tim Mitchell
Hi All, I work on a desktop application that has been developed using python and GTK (see www.leapfrog3d.com). We have around 150k lines of python code (and 200k+ lines of C). We also have a new project manager with a C# background who has deep concerns about the scalability of python as our

Re: error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Jordan
I realize I did a pretty bad job of explaining the problem. The problem is the python version is returning an r that is WY to big. Here is an example run through that function in each language: C: u starts at 1050 u += 0xe91aaa35; u is now -384127409 u ^= u >> 16; u

Re: Manipulating bitsets in struct

2008-07-09 Thread Marc 'BlackJack' Rintsch
On Wed, 09 Jul 2008 20:04:24 -0400, Allen wrote: > I'm using Python to do some simple network programming, and found the > struct module very useful for such things, but is there a way to easily > manipulate bitsets such as a 16 bit word being split into 4 parts like 2 > bits, 1 bit, 4 bits, an

Re: Python and decimal character entities over 128.

2008-07-09 Thread Marc 'BlackJack' Rintsch
On Wed, 09 Jul 2008 16:39:24 -0700, bsagert wrote: > Some web feeds use decimal character entities that seem to confuse > Python (or me). I guess they confuse you. Python is fine. > For example, the string "doesn't" may be coded as "doesn’t" which > should produce a right leaning apostrophe. Py

Re: python scalability

2008-07-09 Thread Jake Anderson
Tim Mitchell wrote: Hi All, I work on a desktop application that has been developed using python and GTK (see www.leapfrog3d.com). We have around 150k lines of python code (and 200k+ lines of C). We also have a new project manager with a C# background who has deep concerns about the scalabi

Re: python scalability

2008-07-09 Thread Daniel Fetchinson
>> I work on a desktop application that has been developed using python >> and GTK (see www.leapfrog3d.com). We have around 150k lines of python >> code (and 200k+ lines of C). We also have a new project manager with >> a C# background who has deep concerns about the scalability of python >> as o

Re: variable question

2008-07-09 Thread Terry Reedy
Support Desk wrote: I am trying to assign a variable using an if / else statement like so: If condition1: Variable = something If condition2: Variable = something else Do stuff with variable. But the variable assignment doesn’t survive outside the if statement.

Re: error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Jordan
if after the first step (u += 0xe91aaa35) you apply this function: invert = lambda x: ~int(hex(0x - x)[0:-1],16) it returns the correct value (corrected the overflow) but there is still something wrong, still looking into it, if someone knows how to do this, feel free to comment :) -- ht

Re: Relative Package Import

2008-07-09 Thread Peter Otten
Kay Schluehr wrote: > On 8 Jul., 21:09, Peter Otten <[EMAIL PROTECTED]> wrote: >> Robert Hancock wrote: >> > mypackage/ >> > __init__.py >> > push/ >> > __init__.py >> > dest.py >> > feed/ >> >__init__py >> >

Re: "in"consistency?

2008-07-09 Thread Terry Reedy
castironpi wrote: On Jul 8, 2:25 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: Compare to an imaginary "set of ints" data type: a= setofints( [ 0, 1, 2 ] ) Then, the semantics of b= setofints( [ 0, 1 ] ) b in a True are consistent and predictable. Correct me if I'm wrong. If you defi

Re: socket-module: different behaviour on windows / unix when a timeout is set

2008-07-09 Thread A.T.Hofkamp
On 2008-07-09, Mirko Vogt <[EMAIL PROTECTED]> wrote: > Is that behaviour common or even documented? Found nothing. Second sentence in the socket module documentation: Note: Some behavior may be platform dependent, since calls are made to the operating system socket APIs. So yes, what you found i

Re: TypeError, I know why but not how!?

2008-07-09 Thread A.T.Hofkamp
On 2008-07-10, ssecorp <[EMAIL PROTECTED]> wrote: > > def validate(placed): > student = round(random.random()*401) > if student in placed: > validate(placed) > else: > placed.append(student) > return student, placed > > def pair(incompatibles, placed): > stud

Re: error when porting C code to Python (bitwise manipulation)

2008-07-09 Thread Peter Otten
Jordan wrote: > C: > > u starts at 1050 > > u += 0xe91aaa35; > > u is now -384127409 Hm, a negative unsigned... > Python: > >    u starts at 1050 > >    u += 0xe91aaa35 > >    u is now  3910839887L Seriously, masking off the leading ones is the way to go: >>> -384127409 & 0x == 3

Re: You, spare time and SyntaxError

2008-07-09 Thread cokofreedom
> > just... great !-) > Thanks :) -- http://mail.python.org/mailman/listinfo/python-list

<    1   2