# Serpent function to compare strings

I would like to write a simple Serpent function that involves string comparison, but even the simplest example I can think of does not work as I would like. This post gets me part of the way . . .

Here is an example (using an IDE like PyCharm, so no carats `>`) to compare two strings as input arguments:

``````import serpent
from ethereum import tester as t, abi

str_compare_code = '''
# What I want to do, check equality of strings
def str_compare(in_a:str, in_b:str):
return(in_a == in_b)

# To show conversion of short strings to numbers in Serpent
def str_number(in:str):
return(in)

# To make even clearer what is funny
def str_diff(in_a:str, in_b:str):
return(in_a != in_b)
'''

# Initialize tester and compile Serpent code
s = t.state()
c = s.abi_contract(str_compare_code)
``````

I test the contract and get

``````In[35]: c.str_compare("a", "a")

('b1', 1000000000000000000000000L)
('b2', 999999999999999996858408L)
('b3', 1000000000000000000000000L, 1)
Out[35]: 0
``````

I know that short strings get converted to ints, as seen here

``````In[36]: c.str_number("a")

('b1', 1000000000000000000000000L)
('b2', 999999999999999996858408L)
('b3', 1000000000000000000000000L, 1)
Out[36]: 352
``````

To put salt in my wounds . . .

``````In[37]: c.str_diff("a", "a")

('b1', 1000000000000000000000000L)
('b2', 999999999999999996858408L)
('b3', 1000000000000000000000000L, 1)
Out[37]: 1
``````

Is the problem how I handle the input strings in the function body? Thank you for any and all tips!