10 sec poll - please reply!

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Nov 20 11:21:07 EST 2012


On Tue, 20 Nov 2012 07:18:42 -0800, Michael Herrmann wrote:

> Thanks again for your further replies. So far, it's 4 votes for
> 'send_keys' and 1 vote for 'type'.
> 
> Regarding 'send_keys': To me personally it makes sense to send keys _to_
> something. However, in our API, send_keys would not be called on an
> object or with a parameter indicating the target. It would just be
> 
> send_keys(ENTER)
> send_keys("Hello World!")
> send_keys(CTRL + 'a')


"send_keys" is wrong, because you aren't sending keys. You're sending 
strings, except you aren't actually sending strings either, because 
"send" does not make sense without a target. You're automating the typing 
of strings, including control characters.

I believe that your initial instinct for the name of this function was 
correct. It automates typing, so you should call it "type" or (for those 
paranoid about shadowing the built-in, "type_str".



-- 
Steven



More information about the Python-list mailing list