Reputation: 81
I'm getting an error when I want to convert a string to an int
in Python.
I am using Squish
with Python. I don't see what the problem is because the int()
function works fine when I tried in python online console. It's possible to be a Squish problem?
The error:
No matching 'int(str)' overload found: Following overloads are available: int::int() int::int(int) int::int(int *)
Upvotes: 2
Views: 2709
Reputation: 31
Squish replaces several Python symbols/names, including int. To access Python's int do so via Python's __builtin__ module:
import __builtin__
# string representation of an int
a = '3'
# use built-in function to convert to int
b = __builtin__.int(a)
Also see Squish's int vs. Python's int, and for more general information about Python in Squish see Python Notes.
Upvotes: 3
Reputation: 81
I found the problem and obviously it's a Squish problem according to kb.froglogic.com/pages/viewpage.action?pageId=131084. Squish defines its own int() function and that's why I was getting the error
Upvotes: 0