← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #667197]: how can i check if value is integer or string? Err in conversion

 

Question #667197 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/667197

irvinborder posted a new comment:
As a rule, Python doesn't implicitly convert objects from one type to
another1 in order to make operations "make sense", because that would be
confusing: for instance, you might think that '2' + 6 should mean '26',
but someone else might think it should mean 8 or even '8'.  You cannot
concatenate a string and a number (of any kind) in python because those
objects have different definitions of the plus(+) operator which are not
compatible with each other . So in order to solve this
"misunderstanding" between objects:

The old school way is to cast the number to string with the str(anything) method and then concatenate the result with another string.
The more pythonic and recommended way is to use the format method which is very versatile

http://net-informations.com/python/basics/string.htm

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.