so I have the line:
text="Temp :" + TempVar + "C CPUTemp: " + CPUTempVar + "C"
How would I get that to work as a string on text?
You can use format to create a string from your variables.
TempVar = 100
CPUTempVar = 50
text = 'Temp : {}C CPUTemp: {}C'.format(TempVar,CPUTempVar)
>>> text
'Temp : 100C CPUTemp: 50C'
'Temp : {0}C CPUTemp: {1}C'.format(TempVar,CPUTempVar). I know 2.6 is a bit long in the tooth now, and later versions don't need that much specification, but I still see a good deal of it in use, so any code I distribute widely, I put the indices in.I endorse @Cyber's answer (the format method) as the straightforward, modern Python way to format strings.
For completeness, however, the old way (common prior to Python 2.6) was a string interpolation operator:
text = 'Temp : %dC CPUTemp: %dC' % (TempVar,CPUTempVar)
It still works in the latest Python 3 releases, and will commonly be seen in older code.
Or you could use my say package to do inline string substitution (or printing) similar to what you'd expect from Ruby, Perl, PHP, etc.:
from say import *
text = fmt('Temp : {TempVar}C CPUTemp: {CPUTempVar}C')