10 sec poll - please reply!

Discussion in 'Python' started by Michael Herrmann, Nov 20, 2012.

  1. Hi,

    I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes.. I currently have it as 'type' but that clashes with the built-in function.. Example uses of 'type':

    type(ENTER)

    type("Hello World!")

    type(CTRL + 'a')

    What, in your view, would be the most intuitive alternative name?

    Here are my thoughts so far: I could call it 'press' but then our GUI automation tool also allows you to click things and then "press" might be mistaken for "pressing a button". A less ambiguous alternative is "type_keys" butthat is rather long and doesn't read as well, for instance in type_keys(ENTER).

    Thank you very much!
    Michael Herrmann, Nov 20, 2012
    #1
    1. Advertising

  2. On Tue, Nov 20, 2012 at 11:18 PM, Michael Herrmann
    <> wrote:
    > Hi,
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    > type(ENTER)
    >
    > type("Hello World!")
    >
    > type(CTRL + 'a')
    >
    > What, in your view, would be the most intuitive alternative name?


    I've done similar things under names like "send_keys".

    ChrisA
    Chris Angelico, Nov 20, 2012
    #2
    1. Advertising

  3. You know, you would probably get more responses if you picked a
    descriptive subject line that didn't look like spam. I only read your
    post because I accidentally clicked on it.

    On Tue, 20 Nov 2012 04:18:38 -0800, Michael Herrmann wrote:

    > I'm developing a GUI Automation library (http://www.getautoma.com) and


    By the way, your website is down.


    > am having difficulty picking a name for the function that simulates key
    > strokes. I currently have it as 'type' but that clashes with the
    > built-in function. Example uses of 'type':
    >
    > type(ENTER)
    > type("Hello World!")
    > type(CTRL + 'a')
    >
    > What, in your view, would be the most intuitive alternative name?



    I'd keep the name as "type". It exists in a different namespace to the
    builtin, so people have a choice: they can refer to the fully-qualified
    name, or not, as they prefer. I don't know the name of your module, since
    your website is down, but let's say it's called "automata":

    # Option 1
    import automata
    automata.type("Hello World")


    # Option 2
    from automata import type
    type("Hello World"
    import builtins # in Python 2 use __builtin__ instead
    builtins.type([])



    So the name clash doesn't matter.



    --
    Steven
    Steven D'Aprano, Nov 20, 2012
    #3
  4. Hi,

    thank you for your replies. So far two people said 'send_keys' and one person said 'type'.

    Steven, thanks for your reply. Sorry if the message title disturbed you. Mypersonal feelings aren't too strongly against 'type' either, but then I'm afraid it might bother more experienced Python programmers who are used to a very different meaning of 'type'. Do you think that could be a problem?

    Thanks again to all who have replied,
    Michael

    On Tuesday, November 20, 2012 1:18:38 PM UTC+1, Michael Herrmann wrote:
    > Hi,
    >
    >
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and amhaving difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    >
    >
    > type(ENTER)
    >
    >
    >
    > type("Hello World!")
    >
    >
    >
    > type(CTRL + 'a')
    >
    >
    >
    > What, in your view, would be the most intuitive alternative name?
    >
    >
    >
    > Here are my thoughts so far: I could call it 'press' but then our GUI automation tool also allows you to click things and then "press" might be mistaken for "pressing a button". A less ambiguous alternative is "type_keys" but that is rather long and doesn't read as well, for instance in type_keys(ENTER).
    >
    >
    >
    > Thank you very much!
    Michael Herrmann, Nov 20, 2012
    #4
  5. P.S.: The website is back online; our hosting provider was having technicalproblems...

    On Tuesday, November 20, 2012 1:18:38 PM UTC+1, Michael Herrmann wrote:
    > Hi,
    >
    >
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and amhaving difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    >
    >
    > type(ENTER)
    >
    >
    >
    > type("Hello World!")
    >
    >
    >
    > type(CTRL + 'a')
    >
    >
    >
    > What, in your view, would be the most intuitive alternative name?
    >
    >
    >
    > Here are my thoughts so far: I could call it 'press' but then our GUI automation tool also allows you to click things and then "press" might be mistaken for "pressing a button". A less ambiguous alternative is "type_keys" but that is rather long and doesn't read as well, for instance in type_keys(ENTER).
    >
    >
    >
    > Thank you very much!
    Michael Herrmann, Nov 20, 2012
    #5
  6. Michael Herrmann

    Dave Angel Guest

    On 11/20/2012 07:18 AM, Michael Herrmann wrote:
    > Hi,
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    > type(ENTER)
    >
    > type("Hello World!")
    >
    > type(CTRL + 'a')
    >
    > What, in your view, would be the most intuitive alternative name?
    >
    > Here are my thoughts so far: I could call it 'press' but then our GUI automation tool also allows you to click things and then "press" might be mistaken for "pressing a button". A less ambiguous alternative is "type_keys" but that is rather long and doesn't read as well, for instance in type_keys(ENTER).
    >
    > Thank you very much!


    I also vote for send_keys(), even before I saw Chris' reply.

    'type' is too overloaded a word. For example, in Windows, it's the
    command to display the contents of a file - it types it to the screen.
    Dave Angel, Nov 20, 2012
    #6
  7. Michael Herrmann

    Neil Cerutti Guest

    On 2012-11-20, Dave Angel <> wrote:
    > I also vote for send_keys(), even before I saw Chris' reply.
    >
    > 'type' is too overloaded a word. For example, in Windows, it's
    > the command to display the contents of a file - it types it to
    > the screen.


    type is a nice verb, but since it's also a well-used noun it's
    perhaps not quite as good as send.

    --
    Neil Cerutti
    Neil Cerutti, Nov 20, 2012
    #7
  8. 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 orwith a parameter indicating the target. It would just be

    send_keys(ENTER)
    send_keys("Hello World!")
    send_keys(CTRL + 'a')

    Does that change your preference for 'send_keys'?

    Thanks a lot!!!

    On Tuesday, November 20, 2012 1:18:38 PM UTC+1, Michael Herrmann wrote:
    > Hi,
    >
    >
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and amhaving difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    >
    >
    > type(ENTER)
    >
    >
    >
    > type("Hello World!")
    >
    >
    >
    > type(CTRL + 'a')
    >
    >
    >
    > What, in your view, would be the most intuitive alternative name?
    >
    >
    >
    > Here are my thoughts so far: I could call it 'press' but then our GUI automation tool also allows you to click things and then "press" might be mistaken for "pressing a button". A less ambiguous alternative is "type_keys" but that is rather long and doesn't read as well, for instance in type_keys(ENTER).
    >
    >
    >
    > Thank you very much!
    Michael Herrmann, Nov 20, 2012
    #8
  9. Michael Herrmann

    MRAB Guest

    On 2012-11-20 15:18, 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')
    >
    > Does that change your preference for 'send_keys'?
    >

    Calling it "send_keys" does have precedent.

    There's a module called SendKeys which uses the SendKeys system call in
    Windows. Unfortunately, the last version was for Python 2.6.

    When I wanted the functionality for Python 3.3 I had to write my own.
    MRAB, Nov 20, 2012
    #9
  10. Michael Herrmann

    John Gordon Guest

    In <> Michael Herrmann <> writes:

    > What, in your view, would be the most intuitive alternative name?


    keyboard_input().

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
    John Gordon, Nov 20, 2012
    #10
  11. Michael Herrmann

    Dave Angel Guest

    On 11/20/2012 11:09 AM, John Gordon wrote:
    > In <> Michael Herrmann <> writes:
    >
    >> What, in your view, would be the most intuitive alternative name?

    > keyboard_input().
    >


    Well, since Python already has input() and raw_input(), it would then be
    clear that keyboard_input() would take some kind of data from the
    keyboard, not send it.



    --

    DaveA
    Dave Angel, Nov 20, 2012
    #11
  12. 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
    Steven D'Aprano, Nov 20, 2012
    #12
  13. Michael Herrmann

    emile Guest

    On 11/20/2012 04:18 AM, Michael Herrmann wrote:
    > Hi,
    >
    > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':
    >
    > type(ENTER)
    >
    > type("Hello World!")
    >
    > type(CTRL + 'a')
    >
    > What, in your view, would be the most intuitive alternative name?
    >
    > Here are my thoughts so far: I could call it 'press'


    I have several tools that distinguish between press and release for
    this. You may want to consider having both.

    Emile
    emile, Nov 20, 2012
    #13
  14. Michael Herrmann

    Guest

    That's a very good suggestion Emile!! So I might eventually need both 'press' and 'release' (or press_key/release_key). Thanks for this!

    To everyone else who has been so kind to reply thus far: What do you think of generate_keystrokes? It's a bit long but describes exactly what the function would be doing.

    All of you are a great help and I really appreciate it. Thank you!

    Michael

    On Tuesday, 20 November 2012 17:21:38 UTC+1, emile wrote:
    > On 11/20/2012 04:18 AM, Michael Herrmann wrote:
    >
    > > Hi,

    >
    > >

    >
    > > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':

    >
    > >

    >
    > > type(ENTER)

    >
    > >

    >
    > > type("Hello World!")

    >
    > >

    >
    > > type(CTRL + 'a')

    >
    > >

    >
    > > What, in your view, would be the most intuitive alternative name?

    >
    > >

    >
    > > Here are my thoughts so far: I could call it 'press'

    >
    >
    >
    > I have several tools that distinguish between press and release for
    >
    > this. You may want to consider having both.
    >
    >
    >
    > Emile
    , Nov 20, 2012
    #14
  15. Michael Herrmann

    Guest

    That's a very good suggestion Emile!! So I might eventually need both 'press' and 'release' (or press_key/release_key). Thanks for this!

    To everyone else who has been so kind to reply thus far: What do you think of generate_keystrokes? It's a bit long but describes exactly what the function would be doing.

    All of you are a great help and I really appreciate it. Thank you!

    Michael

    On Tuesday, 20 November 2012 17:21:38 UTC+1, emile wrote:
    > On 11/20/2012 04:18 AM, Michael Herrmann wrote:
    >
    > > Hi,

    >
    > >

    >
    > > I'm developing a GUI Automation library (http://www.getautoma.com) and am having difficulty picking a name for the function that simulates key strokes. I currently have it as 'type' but that clashes with the built-in function. Example uses of 'type':

    >
    > >

    >
    > > type(ENTER)

    >
    > >

    >
    > > type("Hello World!")

    >
    > >

    >
    > > type(CTRL + 'a')

    >
    > >

    >
    > > What, in your view, would be the most intuitive alternative name?

    >
    > >

    >
    > > Here are my thoughts so far: I could call it 'press'

    >
    >
    >
    > I have several tools that distinguish between press and release for
    >
    > this. You may want to consider having both.
    >
    >
    >
    > Emile
    , Nov 20, 2012
    #15
  16. On 20/11/2012 15:18, 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')


    In that case I'd just call it keys, that shouldn't cause too much
    confusion :) Though keys_pressed comes to mind as an alternative.

    >
    > Does that change your preference for 'send_keys'?
    >
    > Thanks a lot!!!
    >


    --
    Cheers.

    Mark Lawrence.
    Mark Lawrence, Nov 20, 2012
    #16
  17. Michael Herrmann

    Guest

    How to use the python to do the unit test

    I write a mfc application, then I want to use the python to test this application. just as user click that button. Please tell me how to write the python application?
    , Nov 20, 2012
    #17
  18. Michael Herrmann

    emile Guest

    Re: How to use the python to do the unit test

    On 11/20/2012 09:40 AM, wrote:
    > I write a mfc application, then I want to use the python to test this application. just as user click that button. Please tell me how to write the python application?


    I currently use MacroScheduler (http://www.mjtnet.com/) then write
    macros from within python and run them using the commands module to test.

    Emile
    emile, Nov 20, 2012
    #18
  19. On Wed, Nov 21, 2012 at 3:21 AM, Steven D'Aprano
    <> wrote:
    > 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.


    That depends on what the function actually does. If it sends a single
    command to blat a string, including control characters, to the target,
    then yes, it's sending a string. But if, as my reading of the OP tells
    me, the last one is "send press-Ctrl, send press-a, send release-a,
    send release-Ctrl", then it's sending keys, and the name should say
    so. And it's this method that the key-sender in the Yosemite project
    uses (though, for hysterical raisins, its function is called "dokey" -
    which I am NOT recommending).

    ChrisA
    Chris Angelico, Nov 20, 2012
    #19
  20. Steven D'Aprano wrote:

    >
    > 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.


    simulate_keypress
    simulate_key(s)_down
    send_kb_press
    fake_typing
    send_char(s)


    >
    > 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 thebuilt-in, "type_str".
    >


    I can too easily see somebody doing from module import *
    OR from module import type.


    ~Ramit



    This email is confidential and subject to important disclaimers and
    conditions including on offers for the purchase or sale of
    securities, accuracy and completeness of information, viruses,
    confidentiality, legal privilege, and legal entity disclaimers,
    available at http://www.jpmorgan.com/pages/disclosures/email.
    Prasad, Ramit, Nov 20, 2012
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davidj411
    Replies:
    1
    Views:
    1,016
    Mike Driscoll
    May 27, 2008
  2. Replies:
    2
    Views:
    532
  3. birdsong

    select.poll.poll() never blocks

    birdsong, Feb 12, 2009, in forum: Python
    Replies:
    2
    Views:
    443
    birdsong
    Feb 12, 2009
  4. Jean-Paul Calderone

    Re: select.poll.poll() never blocks

    Jean-Paul Calderone, Feb 12, 2009, in forum: Python
    Replies:
    3
    Views:
    433
    birdsong
    Feb 12, 2009
  5. Paka Small
    Replies:
    15
    Views:
    909
Loading...

Share This Page