2

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 *)
Eb946207
  • 748
  • 8
  • 26
Ruxi Ierima
  • 81
  • 1
  • 1
  • 6
  • 2
    Definitely a Squish problem, since Python doesn't even *have* overloading. – chepner Dec 09 '18 at 17:25
  • Definitely, this looks like a C++ error - the underlying library is receiving a string where it expects an integer. We can't say more without seeing the code. – Paulo Scardine Dec 09 '18 at 17:41

2 Answers2

2

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.

frog.ca
  • 684
  • 4
  • 8
xxRMxx
  • 21
  • 2
0

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

Ruxi Ierima
  • 81
  • 1
  • 1
  • 6