

Ask HN: Why is Python so strict about automatically casting differently typed literals? - noaharc

I hate having to use str() and int() all the time.  Am I doing something wrong?  If not, what is the reasoning behind their requirement?  I think most of the automatic casts are pretty well defined in any given situation.
======
mcav
I rarely use str() and int() unless I'm doing conversion of user input (e.g.
web apps). You'd have to be more specific about your usage.

For instance, string formatting doesn't require casts -- just pretend
everything's a string:

    
    
        >>> print "%s %s %s = %s" % (4, '-', 1, 3)
        4 - 1 = 3

~~~
makecheck
True, unless the format is inherently numerical; e.g. if you care about
significant digits (something like "%.4f") or padding (something like "%4d"),
there's no way to do it without an actual number.

------
bayareaguy
Explicit is better than implicit.

