[Tutor] Error in printing out totalSystolic on paper (1018)

Ken G. beachkidken at gmail.com
Sun Aug 10 16:59:52 CEST 2014


On 08/10/2014 10:38 AM, Alex Kleider wrote:
> On 2014-08-10 06:41, Ken G. wrote:
>> Receiving the following error from the terminal screen:
>>
>> Traceback (most recent call last):
>>   File "Blood Pressure05Print45.py", line 95, in <module>
>> pr.write(totalSystolic)
>> TypeError: expected a character buffer object
>>
>> Portion of strip:
>> =================
>>
>>     pr.write (" "), pr.write (pulse), pr.write ("\n")
>>     totalSystolic = totalSystolic + int(systolic)
>>     totalDiastolic = totalDiastolic + int(diastolic)
>>     totalPulse = totalPulse + int(pulse)
>> file1.close()
>> print
>> print totalSystolic, totalDiastolic, totalPulse
>>
>> # sys.exit()
>>
>> pr.write(totalSystolic)
>> # pr.write(totalDiastolic)
>> # pr.write(totalPulse)
>>
>> ==========================
>>
>> I know that totalSystolic is 1018, totalDiastolic is 469 and
>> totalPulse is 465.
>>
>> I can not figure out why pr.write won't print out 1018 on paper.
>>
>> Using Python 2.7 on Ubuntu 12.04.5 and using Geany to process the strip.
>>
>> Thanks for your suggestion.
>>
>> Ken
>
>
> I'm guessing that you've defined pr.write(<string>) to take a string 
> object but have fed it an integer- hence type error: try 
> pr.write(str(totalSystolic))
> instead of just pr.write(totalSystolic)
>
> By the way, those are incredibly high numbers! What units are you using?

Thank you, I will try pr.write(str(totalSystolic)). As for the high
numbers, they are a total of 8 readings, therefore,

Systolic:  1018/8 = 127.25
Diastolic:  469/8 = 58.625
Pulse:      465/8 = 58.125

Again, thanks.

Ken


More information about the Tutor mailing list