Program runs in all directories, except one..
John Machin
sjmachin at lexicon.net
Sat Apr 28 09:22:45 EDT 2007
On Apr 28, 9:50 pm, "Theo v. Werkhoven" <t... at van-
werkhoven.nl.invalid> wrote:
> Goodday,
>
> Something strange going on here.
> A piece of code I wrote bombs out in one of de directories under $HOME,
> but not in others.
[snip]
> def shiftout(numoctets):
> os.system('clear')
> ser = serial.Serial(0)
> from array import array
> octarray = [0]
> for i in range(0,numoctets-1):
> octarray.append(0)
>
> for octet in range(numoctets,0,-1):
> octarray[octet-1]=1
> for shift in range(0,8):
> strg = array("B",octarray).tostring()
The above statement appears to be where the error manifests itself.
Possibilities: (1) array is bound to a list (2) the result of
array("B", octarray) has an attribute tostring which is bound to a
list. Option (1) seems less implausible. I'd be replacing that line
by:
print "octet %r, shift %r, array %r" % (octet, shift, array)
array_b = array("B", octarray)
print "array_b %r" % array_b
print "array_b.tostring %r" % array_b.tostring
strg = array_b.tostring()
You haven't shown us all of your code -- is array mentioned elsewhere?
What other imports are you doing? Do you have a file called array.py
in the offending directory? [I believe that this wouldn't matter,
because builtin modules like array can't be overridden by a file-based
module of the same name, but I could be wrong]
What platform and what version of Python?
HTH,
John
More information about the Python-list
mailing list