Re: Python for low-level Windows programming

2008-04-03 Thread Troels Thomsen
>> >> Is this possible without too much pain? I know I can code it with C# >> or C++ but tha'ts a road to avoid, if possible. > > Well of course I don't know exactly what you'd need, but the > answer's certainly Yes :) Need I mention that it is also easy to write a windows service, using pyservic

1.5.2 and functools or similar

2008-03-09 Thread Troels Thomsen
Hello, I am writing a simple delayed-call mechanism , that is causing a bit of headache. Works like this: myPrint(s) print "..." + s myTimer.add(myPrint , "hello" , 15) This means that the myprint function is called in 15 seconds with the parameter "hello". The housekeeping of these timers

Re: for-else

2008-03-05 Thread Troels Thomsen
> > The primary use case is searching a container: > > prep_tasks() > for item in container: > if predicate(item): > found_tasks() > break > else: > not_found_tasks() > follow_up_tasks > I've found myself mimicing this again and again in c, and was pleased

Re: Does anyone else use this little idiom?

2008-02-03 Thread Troels Thomsen
>for action in repeat(f, n): action() >I don't know how 'Pythonic' this would be... agree, or this: import itertools def f1(): print "hello" [f() for f in itertools.repeat(f1,6)] tpt -- http://mail.python.org/mailman/listinfo/python-list

int vs long

2007-12-16 Thread Troels Thomsen
The readFile function from the win32 package aparently really expect an integer : def inWaiting(self): """Returns the number of bytes waiting to be read""" flags, comstat = ClearCommError(self.__handle) return comstat.cbInQue ReadFile(h, s.inWaiting()) My code crash

Re: ironpython exception line number

2007-06-30 Thread Troels Thomsen
>If you're hosting IronPython and catching this from a .NET language >then you'll be catching the .NET exception. Yes >In that case you can access the original Python exception >from ex.Data["PythonExceptionInfo"]. Yes ! YES ! Thx regards tpt -- http://mail.python.org/mailman/listinfo/pytho

ironpython exception line number

2007-06-26 Thread Troels Thomsen
Hello , When an exeption occurs in a IronPython executet script, and I print the sys.exc , i get something ugly like the example below. How can I get the fileName and line number? Thx in advance Troels 26-06-2007 13:19:04 : IronPython.Runtime.Exceptions.PythonIndentationError: unexpected tok

Re: [pyserial - winXP] Serial port stop receiving data after a few hours, raise no error

2007-06-06 Thread Troels Thomsen
I read that when the serial port encounters an error (frame error or so, I imagine?) it stop receiving data until the library function "getCommError()" is called. Troels: I think you are right Am I on the good track? Can I call this function from my pyserial code? Why pyserial does'nt raise a s

Re: how to print out each single char from a string in HEX format?

2007-06-05 Thread Troels Thomsen
> Great! It works. > There is a builtin function called hex() that does the same, but also shares the same problem as the solution above: >>> hex(10) '0xa' >>> This is probably not "nice" in your printouts, it doesn't allign. with the printf inspired solution you can set the precision like

call function in console without paranthesis

2007-05-31 Thread Troels Thomsen
Hello, I am wondering if I can write some code, that allows me to call functions in the console , IDLE, without using the paranthesis notation. Like print. This will improve "intreractive'ness" serialOpen() # some magic is issued here !!! tx Hello instead of serialObj = mySerial() serialObj

Re: Scope - import and globals

2007-05-29 Thread Troels Thomsen
"HMS Surprise" <[EMAIL PROTECTED]> skrev i en meddelelse news:[EMAIL PROTECTED] > > In the file snippet below the value for the global hostName is > determined at runtime. Functions imported from the parent baseClass > file such as logon also need access to this variable but cannot see it > the

stdout and threads

2007-05-28 Thread Troels Thomsen
Hello All I have trouble printing to stdout from a thread and main program. Not only will it look strange when they try to print at the same time, that is ok, but i think i see lock-ups. (strange exceptions in Tkinker etc) Or is it an issue with IDLE ? Should I implement a lock'ed / queued ver