type("%")

Asked by Queue

What escape character do I need to to be able to pass % through the type() function?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

related to question https://answers.launchpad.net/sikuli/+question/101782

I will report a bug.

use paste() instead of type().

This works perfectly for putting something into input fields (like the browser address field) that have the focus.

The single percent is interpreted as the formatting operator (don't ask me why in this case). The python way to escape the % is to use %% for one. this works (no error) but it types %% instead of %. The traceback shows, that the error starts with the Sikuli type module. may be the wrong java functions are used.

x="%%%s" % "abc%3D" # use of the formatting operator
print x # works: %abc%3D
type(x) # error
paste(x) # works too

its weird, because this means, the string given to type() containing a % is interpreted as as a formatting string, without the %-operator being there.

Revision history for this message
Queue (jcy2k03) said :
#2

Thank you so much; this makes my code so much shorter/tidier.

Revision history for this message
Queue (jcy2k03) said :
#3

Thanks RaiMan, that solved my question.