[Baypiggies] Is this a conversion problem? Can I get help to resolve this please?

David Elsen elsen.david08 at gmail.com
Wed Aug 27 01:21:05 CEST 2008


Hi Sherman.

Thanks. It worked for me. My mistake. Sorry for being such a stupid.

I am forwarding the Sherman reply to the whole group. Just in case someone
need it
David


>
>   On Tue, Aug 26, 2008 at 1:30 PM, Shiqi Yang <sherman.yang at gmail.com>wrote:
>
>> just saw reg[0] is a list type
>> in that case maybe
>> int(reg[0][0], 16) would work for you.
>>
>>
>>
>> On Tue, Aug 26, 2008 at 1:28 PM, David Elsen <elsen.david08 at gmail.com>
>> wrote:
>> > Hi Sherman,
>> >
>> > With int(reg[0],16), I get the error message "TypeError: int() can't
>> convert
>> > non-string with explicit base."
>> >
>> > On Tue, Aug 26, 2008 at 1:23 PM, Shiqi Yang <sherman.yang at gmail.com>
>> wrote:
>> >>
>> >> Hi, David,
>> >>
>> >> you can give int(reg[0], 16) a try to see if that's what you want.
>> >>
>> >>
>> >>
>> >>
>> >> On Tue, Aug 26, 2008 at 1:02 PM, David Elsen <elsen.david08 at gmail.com>
>> >> wrote:
>> >> > Hi all,
>> >> >
>> >> > I have a test script as follows:
>> >> >
>> >> > import os
>> >> > import string
>> >> > cmd = './testtool  dump'
>> >> > res = os.popen(cmd).read()
>> >> > #print res
>> >> > #fout = open("ask_it.txt", "w")
>> >> > #fout.write(res)
>> >> > #fout.close
>> >> > reg_reset_val = []
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> > reg_reset_val.append(0xdeadfeed)
>> >> >
>> >> > print 'reg default values'
>> >> > for index, item in enumerate(reg_reset_val):
>> >> >  print index, item
>> >> >
>> >> > fin = open ("ask_it.txt", "r")
>> >> > i = 0
>> >> > reg = []
>> >> > linelist = fin.readlines()
>> >> > lines = len(linelist)
>> >> > for line in linelist:
>> >> >  i = i +1
>> >> >  if (i >= 5): # First four lines are bogus
>> >> >   datas = line.split()
>> >> >   reg.append(datas)
>> >> >   if i == lines:
>> >> >    break
>> >> > print 'the reg list is'
>> >> > for j, item in enumerate(reg):
>> >> >  print j, item
>> >> > print 'reg[0]'
>> >> > print reg[0]
>> >> > print 'reg_reset_val[0]0x%x'%reg_reset_val[0]
>> >> > #print reg_reset_val[0]
>> >> > if (reg[0] == reg_reset_val[0]):
>> >> >  print 'test passed'
>> >> > else:
>> >> >  print 'test failed'
>> >> >
>> >> >
>> >> > Calling to driver via IOCTL Control Memory Dump buf addr = 0x804d008.
>> >> > Returned from calling driver via IOCTL.
>> >> > IOCTL CTL Mem Dump char count
>> >> > Control Memory Dump:  Address 0xf8812000
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > 0xdeadfeed
>> >> > I am expecting the "reg[0]" and "reg_reset_val[0]" to be the same.
>> But
>> >> > reg[0] is list and has ['0xdeadfeed'] in it and reg_reset_val[0] has
>> >> > 0xdeadfeed in it. How can I convert the reg[0] to make it normal
>> >> > 0xdeadfeed.
>> >> >
>> >> > Thanks,
>> >> > David
>> >> >
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Baypiggies mailing list
>> >> > Baypiggies at python.org
>> >> > To change your subscription options or unsubscribe:
>> >> > http://mail.python.org/mailman/listinfo/baypiggies
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Sherman Yang
>> >
>> >
>>
>>
>>
>> --
>> Sherman Yang
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20080826/4b0b53e4/attachment.htm>


More information about the Baypiggies mailing list