Python automatically coerces the number to a string, while Racket will not do so. Neither Racket nor Python will coerce the number into a string. That is why you must use number->string
explicitly in Racket, and str()
in Python ("p" + str(3)
). You may also find Racket's format
function to behave similarly to some uses of Python's %
operator:
# Python
"py %d %f" % (3, 2.2)
;; Racket
(format "rkt ~a ~a" 3 2.2)
But there is no Racket nor Python equivalent to "foo" + 3
that I know of.
[Answer edited per my mistake. I was confusing Python behavior with JavaScript, misled by OP]