[Tutor] Spyder - How to determine files that appear at start-up
My question concerns Spyder. I know that this is a Python list, but I also see that some people here also use Spyder. So, please forgive me. My problem is simple. I cannot find out how I can determine the set of files that open at start-up. I am annoyed by the fact that I must manually load my set of working files each time that I start Spyder. Thanks. Sydney _ Professor Sydney Shall Department of Haematology/Oncology Phone: +(0)2078489200 E-Mail: sydney.shall [Correspondents outside the College should add @kcl.ac.uk] ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'
All, Sorry for not being more clear. I think I was nearing my fill of Python for the day when I wrote. Now, refreshed, let me see if I can fill in the blanks a bit more. - Bits that are shifted in either direction off the end of the 64-byte(or 'n' size) collection are of no use. They are actually phantom bits created by the hardware that I'm trying to get rid of by using this shifting. And, the desired data needs to be properly aligned so I can work with it as well. - Any bits that are shifted 'in' from either end are zeros. - What follows is a mini version, the array could be any size up to 64 bytes input: 10010010 . 1110 . 01010011 shift 'x' (for example, I'll use 1) output: 01001001 . 01110111 . 10101001 Some results that I've been getting appear as follows: - 'stuck bits' output: input : 01010011 . 01110001 . 1111 output : 00101001 . 00111000 . 1111 where the most significant bit of the word appears to 'stick' regardless of the shifting. This isn't the best example. - 'roll over' output" input : 0001 . . 10001000 output : . 1000 . 01000100 The most significant byte here has the 'roll over' issue. I'm guess this has something to do with sign extension of the byte in the larger Python storage medium. The above are not actual data that have been manipulated by the software but illustrations of observations. The real data is 'random' so I'm doing the best to recall from memory what happens. The data is being returned from the hardware as a bytearray but since I'm reading it a byte at a time, it ends up being stored as a list. I've been using for loops to cycle through the list. Ideally, I'd love to be able to say : # here's the array / list rx_data = [] # read through all the bytes # stash the results into the list for x in range (bytes_of_data): rx_data[x] = read_data()[0] # bit shift the entire lot rx_data = rx_data >> bits_to_shift. Which would provide me with the output described above. Code I've been working with is as follows: def bit_loop_report(disp, num_bits): if(disp): print "++Begin Report" num_bits = 0x00 num_bytes = 0x00 # define some constants to help in bit shifting rt_mask = array ('B', [0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F]) lt_mask = array ('B', [0xFF, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE]) # account for partial bytes worth of stops # determine number of bytes num_bytes = num_bits / 8 # if we have bits left over then save that count # between 1 and 7 inclusive if (num_bits > (num_bytes * 8)): num_bits = num_bits - (num_bytes * 8) print " num bits ", num_bits # if the number of bits left over is non-zero... if(num_bits != 0): # increment byte count to cover the additional bits num_bytes += 1 # calculate the actual number of extra bits rs_extra_bits = 8 - (num_bits % 8) print " extra bits ", rs_extra_bits if(disp): print "Loop size bytes = ", num_bytes # some vars we'll use bit_on = False disp_bit_on = "ON" disp_bit_off = "OFF" bit_state_human_read = "" print "\n\n Use Ctrl-C to Exit \n\n" # create an array to store stop states # last read last_read_ary = array('B', (0x00,)*num_bytes) r_last_read_ary = array('B', (0x00,)*num_bytes) # current read curr_read_ary = array('B', (0x00,)*num_bytes) r_curr_read_ary = array('B', (0x00,)*num_bytes) # hold the stop change results stop_chng_ary = array('B', (0x00,)*num_bytes) # if num_bits is non-zero, we have to shift # the data in the array accordingly done_shft_ary = array('B', (0x00,)*num_bytes) # clear everything out bit_loop_flush(disp) # clear the registers bit_loop_clear(disp) # latch the states bit_loop_strobe(disp) # read in the initial state of the loop # bytes are read in backwards because the # MSByte comes from the hardware first # (MSByte -> LSByte) and MSbit first. for first_read in range (0, num_bytes): # read a byte and stash into the array r_last_read_ary[first_read] = bit_loop_read(disp) # reverse the byte order last_read_ary = list(reversed(r_last_read_ary)) # now we enter a loop waiting for changes # to the data in the loop try: while (True): # zero out the variables read_stop = 0x00 temp_log = 0x00 changed = 0x00
Re: [Tutor] Spyder - How to determine files that appear at start-up
On Mon, 8 Oct 2018 at 13:18, Shall, Sydney via Tutor wrote: > > My question concerns Spyder. I know that this is a Python list, but I > also see that some people here also use Spyder. So, please forgive me. > > My problem is simple. I cannot find out how I can determine the set of > files that open at start-up. I am annoyed by the fact that I must > manually load my set of working files each time that I start Spyder. Hi Sydney, It looks like this Stack Overflow question has some answers for you: https://stackoverflow.com/questions/14400993/spyder-default-module-import-list -- Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'
On Mon, Oct 08, 2018 at 09:16:16AM -0400, Chip Wachob wrote: > - What follows is a mini version, the array could be any size up to 64 bytes > > input: 10010010 . 1110 . 01010011 > > shift 'x' (for example, I'll use 1) > > output: 01001001 . 01110111 . 10101001 The first two seem to be simple right bit-shift: 10010010 -> 01001001 1110 -> 01110111 but the third seems to be something completely different, neither a left nor a right shift: 01010011 -> 10101001 A left-bit shift would give this: 10100110 and a right shift would give this: 00101001 So now I don't know what you want. [...] > The above are not actual data that have been manipulated by the > software but illustrations of observations. The real data is 'random' > so I'm doing the best to recall from memory what happens. Seriously, "this is what I vaguely remember happening" is no way to debug software. Show us *actual data* with *actual results* and maybe we can help, otherwise we're just pissing into the wind here. [...] > Ideally, I'd love to be able to say : > > # here's the array / list > rx_data = [] > > # read through all the bytes > # stash the results into the list > for x in range (bytes_of_data): >rx_data[x] = read_data()[0] > > # bit shift the entire lot > rx_data = rx_data >> bits_to_shift. > > Which would provide me with the output described above. Take your byte-array returned from read_data, the *lot* of it, not just the first byte. Convert to an int, and shift the int. py> b = bytearray(4) # work with four bytes py> b[1] = 255 # fill in some non-zero values py> b[2] = 127 py> b bytearray(b'\x00\xff\x7f\x00') py> n = int.from_bytes(b, 'big') py> hex(n) '0xff7f00' py> bin(n >> 1) '0b0111000' py> bin(n << 1) '0b01110' Does that help? -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'
On 10/08/2018 07:16 AM, Chip Wachob wrote: > All, > > Sorry for not being more clear. I think I was nearing my fill of > Python for the day when I wrote. > > Now, refreshed, let me see if I can fill in the blanks a bit more. > > - Bits that are shifted in either direction off the end of the > 64-byte(or 'n' size) collection are of no use. They are actually > phantom bits created by the hardware that I'm trying to get rid of by > using this shifting. if you have stray bits, masking is usually a better solution than shifting. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor