Re: [Tutor] Stumped Again

2010-10-30 Thread Steven D'Aprano
Terry Green wrote: Am running this Script and cannot figure out how to close my files, Keep getting msg: Attribute Error: '_csv.writer' object has no attribute 'close' Why? Lesson one: we're not mind readers. To be able to give you useful advise, we need to see the ACTUAL error and not a sum

Re: [Tutor] Stumped Again

2010-10-30 Thread Brian Jones
On Sat, Oct 30, 2010 at 7:12 PM, Terry Green wrote: > *Am running this Script and cannot figure out how to close my files,* > > *Keep getting msg: Attribute Error: ‘_csv.writer’ object has no attribute > ‘close’* > > *Why?* > Because csv.writer objects don't have a close() method. Files do :)

[Tutor] Stumped Again

2010-10-30 Thread Terry Green
Am running this Script and cannot figure out how to close my files, Keep getting msg: Attribute Error: '_csv.writer' object has no attribute 'close' Why? import csv testOutput = csv.writer(open('c:/users/terry/downloads/tup1012k/tup1012.csv', 'w'), delimiter=',', qu

Re: [Tutor] stumped again adding bytes

2007-02-24 Thread shawn bright
Hey there, and thanks for all your help here, i started getting some values that look like what they are supposed to. Funny, i have been with python for over a year, and just downloaded a hex cheatsheet. thanks again for all of the help, gents. shawn On 2/23/07, Alan Gauld <[EMAIL PROTECTED]> wr

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread Alan Gauld
"shawn bright" <[EMAIL PROTECTED]> wrote > if i use i bitmask of 240 it will mask the most significant 4 bits When using bitmasks its much easier to think in hex (or octal). there are exactly 2 hex digits per byte so you only need to think about each group of 4 bits and its hex bit pattern. It

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread Alan Gauld
"shawn bright" <[EMAIL PROTECTED]> wrote > so i believe i do shifting here. as in i do a > (a << 4) * 32 + b > Don't use shifting to extract the bits, use a bitmask and & its much easier. If you want to extract the left-most 4 bits use 0xf0 If you want to extract the righ-most bits use 0x0f 1

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
whoops, meant this to the list, sorry Luke. On 2/23/07, shawn bright <[EMAIL PROTECTED]> wrote: > Thanks for your help, Luke. > i am trying to get a grasp on how all this works, which is the msb, lsb, etc.. > > if i use i bitmask of 240 it will mask the most significant 4 bits > so that only the m

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
Thanks for your help, Luke. i am trying to get a grasp on how all this works, which is the msb, lsb, etc.. if i use i bitmask of 240 it will mask the most significant 4 bits so that only the most significant 4 bits remain.. like 53 & 240 = 48 ( because only the 32 and 16 are set) and if i use 15 i

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread Luke Paireepinart
shawn bright wrote: > ok, i am good with what you have explained here, > now i am on a similar problem. > > the data i need is in a condensed format. in other words, they are > sending 2 values in three bytes. > > so if i have 3 values say a = 53, b = 13, and c = 31 > > so value 1 is the first byte

Re: [Tutor] stumped again adding bytes

2007-02-23 Thread shawn bright
ok, i am good with what you have explained here, now i am on a similar problem. the data i need is in a condensed format. in other words, they are sending 2 values in three bytes. so if i have 3 values say a = 53, b = 13, and c = 31 so value 1 is the first byte ( a ) and the first 4 bits of the

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Kent Johnson
shawn bright wrote: > oh, sorry, i meant how to get the 0x0A27 out of two bytes > a = 0x27 and b = 0x8A Why is the correct result not 0x8A27 ? Maybe this is what you want: >>> a=0x27 >>> b=0x8a >>> (b & 0x7f) * 256 + a 2599 Kent ___ Tutor maillist

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Luke Paireepinart
shawn bright wrote: > oh, sorry, i meant how to get the 0x0A27 out of two bytes > a = 0x27 and b = 0x8A I don't see what the number 0x0A27 has to do with bytes 0x27 and 0x8A, but I'll assume you meant 0x0A for b. > > actually, in my script, i am not using the hex values at all, i have > these beca

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Kent Johnson
shawn bright wrote: > Hey all, thanks for the help yesterday on finding out if an msb is set or not. > > i am now kinda stumped with discovering the value of two bytes together. > > i am making the integers with ord(a) and ord(b) > > how do i put them together ? If this is related to your earli

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread shawn bright
oh, sorry, i meant how to get the 0x0A27 out of two bytes a = 0x27 and b = 0x8A actually, in my script, i am not using the hex values at all, i have these because they are examples in the documentation of a machine i am talking to. i am actually using ord(a) and ord(b) to get digital values of the

Re: [Tutor] stumped again adding bytes

2007-02-21 Thread Luke Paireepinart
shawn bright wrote: > Hey all, thanks for the help yesterday on finding out if an msb is set or not. > > i am now kinda stumped with discovering the value of two bytes together. > > ok, if i have two bytes that together make a number, how do i find that > number? > i know that i do not add them. >

[Tutor] stumped again adding bytes

2007-02-21 Thread shawn bright
Hey all, thanks for the help yesterday on finding out if an msb is set or not. i am now kinda stumped with discovering the value of two bytes together. ok, if i have two bytes that together make a number, how do i find that number? i know that i do not add them. like byte_a = 39 byte_b = 138 to