Re: Non-POSIX parity (mark/space) with Python-Serial on Linux.

2011-11-21 Thread David Riley
On Nov 21, 2011, at 2:29 PM, Matthew Lenz wrote: > Another thing I noticed is that the & and | appear to give the same result as > adding or subtracting 128 from the ordinal value. I'm assuming that isn't > coincidence. :) It's not, though the difference is important. They're binary ANDs (&)

Re: Non-POSIX parity (mark/space) with Python-Serial on Linux.

2011-11-21 Thread David Riley
On Nov 21, 2011, at 12:59 PM, Matthew Lenz wrote: > Thanks, this will be a great help. > > Just wanted to confirm that you meant to use [ .. for x in ord_str] in the > example conversion? Got a TypeError using the received_str. Yes, I probably should have double-checked that. ord_str is indee

Re: Non-POSIX parity (mark/space) with Python-Serial on Linux.

2011-11-21 Thread David Riley
On Nov 21, 2011, at 12:25 PM, gene heskett wrote: > And that is 9600 baud 8n1 on both ends. Ascii is normally 7 bit and will > have a low 8th bit if fed normal ascii data, so how is the 8th bit getting > set other than purposely setting 7M1 on the other end of the cable? That's what I thought

Re: Non-POSIX parity (mark/space) with Python-Serial on Linux.

2011-11-21 Thread David Riley
On Nov 21, 2011, at 11:52 AM, Matthew Lenz wrote: > Ahh. Ok. So how would I go about doing that with python? I think in perl > (sorry for the naughty word) I could use the tr// (translate) but is there a > quick way to do so with python? Is it going to be necessary to convert > commands I SE

Re: Non-POSIX parity (mark/space) with Python-Serial on Linux.

2011-11-21 Thread David Riley
On Nov 21, 2011, at 11:28 AM, Matthew Lenz wrote: > Using 8N1 under minicom with this device resulted in garbled text when once > connected. Connection using 7M1 resulted in the correct text. So there must > be something else that needs to be done in my python program correct? Under minicom i

Re: suppressing import errors

2011-11-15 Thread David Riley
On Nov 15, 2011, at 5:59 PM, Alan Meyer wrote: > On 11/15/2011 4:20 PM, David Riley wrote: > ... >> None was set to some other value. The other value might have a type >> (such as a container) that could be false in a boolean context! >> >> Obviously,

Re: suppressing import errors

2011-11-15 Thread David Riley
On Nov 15, 2011, at 3:01 PM, Chris Angelico wrote: > On Wed, Nov 16, 2011 at 6:39 AM, David Riley wrote: >> True, and that does avoid polluting namespace. However, you shouldn't be >> testing for None as a bool; you should instead do an "if is None:" &

Re: suppressing import errors

2011-11-15 Thread David Riley
On Nov 15, 2011, at 1:58 PM, Jean-Michel Pichavant wrote: > PS : @Dave there is a way to avoiding adding symbols to your global > namespace, assign None to the module's name on import errors. Then before > using it, just test the module bool value : if serial: serial.whateverMethod() True, and

Re: suppressing import errors

2011-11-15 Thread David Riley
On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote: > > > On 15 November 2011 17:24, Chris Kaynor wrote: > As with any Python code, you can wrap the import into a try: except block. > > try: > import badModule > except: > > > pass # Or otherwise handle the exception - possibly importing a

Re: Python lesson please

2011-11-06 Thread David Riley
On Nov 6, 2011, at 3:34 PM, Cameron Simpson wrote: > Perhaps more relevantly: > > If you have unmangled a lot of tabs, remember that control flow is > indentation based in python, and you may have broken some logic. > (For this reason a number of us set our editors to work only in spaces). I wou

Re: Unicode literals and byte string interpretation.

2011-10-27 Thread David Riley
On Oct 27, 2011, at 11:05 PM, Fletcher Johnson wrote: > If I create a new Unicode object u'\x82\xb1\x82\xea\x82\xcd' how does > this creation process interpret the bytes in the byte string? Does it > assume the string represents a utf-16 encoding, at utf-8 encoding, > etc...? > > For reference th

Re: How to use shell return value like $? In python?

2011-10-23 Thread David Riley
On Oct 23, 2011, at 10:44 PM, aaabb...@hotmail.com wrote: > exp: > os.system('ls -al') > #I like to catch return value after this command. 0 or 1,2,3 > does python support to get "$?"? > then I can use something like: > If $?==0: > > From the manual (http://docs.

Re: help

2011-10-23 Thread David Riley
"Libel" and "slander" also generally indicate malice. Perhaps just "That's incorrect" might have come off a little less harsh. :-) - Dave On Oct 23, 2011, at 12:05 PM, Matej Cepl wrote: > Dne 22.10.2011 17:02, Steven D'Aprano napsal(a): >> Rather than assume malice, we should give X1 the ben

sysconfig on OS X 10.7 (Lion) and XCode 4.2

2011-10-20 Thread David Riley
Hello all, I've struggled mightily to get Numpy and pyopencl installed on my brand-new Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for punishment). I did finally succeed, anyway. I found that the greatest problem I had (after installing gfortran from a precompile