On Tue, Aug 24, 2010 at 3:21 PM, Anderson Lizardo
<[email protected]> wrote:
> fact Python does not do that with its builtin functions (please
> provide some example of this, if that's the case). Functions that
> require strings usually require you first converting the argument
> using str() or "%s", **unless** the variable being passed is a subtype
> of str or has the string protocol, in which case the "conversion" is
> expected (technically, I think a conversion does not occur).

Indeed , and Matti just sent an interactive snippet that proves that.
The 'strongly typed' sort of nature has helped me to spot numerous odd
behaviors through conversion errors with the built-ins.


Consider:
t = 1
str = "this is a string"

In [13]: print("output ",t + str)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/sivan/<ipython console> in <module>()

TypeError: unsupported operand type(s) for +: 'int' and 'str'

Or, alternatively :
In [10]: print("output ",str + t)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/sivan/<ipython console> in <module>()

TypeError: cannot concatenate 'str' and 'int' objects


-Sivan
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to