sciter-sdk/pysciter

element.value, when finding things, includes quotes

martinlombana opened this issue · 1 comments

When finding an element value, like such:

<body>
 <editbox name="WHATEVER" value="ferpection"/>
</body>
element: Element = root.find_first("[name~=WHATEVER]")
			if element is not None:
				print('element.value-> ', element.value, flush=True)

This alocates the value of "ferpection", to the string. So the string, becomes, actually: '"ferpection"', with the quotes.

Took me a good time to find this and debug my code because I was getting False check returns, because I was comparing the value of the string with the quotes.

Bottomline, I think, when accessing the value of an element, it should not contain the quotes, because they are not part of the value itself. (Unless there is a good reason for it, somehow). But having to remove them myself, seems cumbersome and prone to error...

Thanks!

The code looks strange.

It should be element.get_value() if it's Python.

As for the quotes - str(value) (which is called by print(value)) is used for the string representation of the value hence the quotes. Use repr(value) for debugging and value.get_value() for converting the Sciter value to a corresponding Python type.

So, to sum up: element.get_value().get_value().