Command parsing... best module to use?

Discussion in 'Python' started by Collin D, Nov 2, 2009.

  1. Collin D

    Collin D Guest

    Hey everyone.

    I am writing a game in python, and it includes a text console somewhat
    like the one in WoW and Runescape. I want to be able to include "/"
    commands, like IRC, and was wondering what the best module would be to
    parse these.

    Thanks a lot,
    Collin D
     
    Collin D, Nov 2, 2009
    #1
    1. Advertising

  2. Collin D

    TerryP Guest

    On Nov 2, 2:27 pm, Collin D <> wrote:
    > Hey everyone.
    >
    > I am writing a game in python, and it includes a text console somewhat
    > like the one in WoW and Runescape. I want to be able to include "/"
    > commands, like IRC, and was wondering what the best module would be to
    > parse these.
    >
    > Thanks a lot,
    > Collin D


    I'm not aware of any module designed for parsing arbitrary text in
    that way, although it may be possible to subvert something to the
    task. If you are following the usual IRC client behavioural pattern,
    then just suck up the line - then see if the first non-whitespace
    character is a '/', then react accordingly. Simple.
     
    TerryP, Nov 2, 2009
    #2
    1. Advertising

  3. Collin D

    Mark Tolonen Guest

    "Collin D" <> wrote in message
    news:...
    > Hey everyone.
    >
    > I am writing a game in python, and it includes a text console somewhat
    > like the one in WoW and Runescape. I want to be able to include "/"
    > commands, like IRC, and was wondering what the best module would be to
    > parse these.


    Check out the pyparsing module. Here is a presentation given by the author
    for parsing an interactive game.

    http://us.pycon.org/zope/talks/2006/fri/track1/04/index.html

    -Mark
     
    Mark Tolonen, Nov 2, 2009
    #3
  4. Collin D

    Collin D Guest

    Thanks for the replies. Pyparsing looks just like what I need.
     
    Collin D, Nov 3, 2009
    #4
  5. Collin D

    Simon Hibbs Guest

    On 3 Nov, 01:14, Collin D <> wrote:
    > Thanks for the replies. Pyparsing looks just like what I need.


    The cmd module in the standard library is fine for simple command
    interpreters. Depending on your needs you might find it does what you
    want. Doug Hellmann has covered it in his "Python module of the week"
    series of articles.

    http://www.doughellmann.com/PyMOTW/cmd/index.html

    Simon Hibbs
     
    Simon Hibbs, Nov 3, 2009
    #5
  6. Collin D

    van Asselt Guest

    Hello Colin,

    I have been using 'cmdloop.py' from Crutcher Dunnavant in a few programs....
    See http://py-cmdloop.googlecode.com/svn/trunk/cmdloop.py

    Regards,
    Henk

    ---------------------

    "Collin D" <> wrote in message
    news:...
    > Hey everyone.
    >
    > I am writing a game in python, and it includes a text console somewhat
    > like the one in WoW and Runescape. I want to be able to include "/"
    > commands, like IRC, and was wondering what the best module would be to
    > parse these.
    >
    > Thanks a lot,
    > Collin D
     
    van Asselt, Nov 7, 2009
    #6
    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. Donald Duck

    Best command for running shell command

    Donald Duck, Jul 11, 2006, in forum: Python
    Replies:
    3
    Views:
    412
    iapain
    Jul 11, 2006
  2. Rafe
    Replies:
    3
    Views:
    287
    Jeremy Sanders
    Dec 1, 2008
  3. GGarramuno

    Command line parsing module

    GGarramuno, Dec 27, 2003, in forum: Ruby
    Replies:
    1
    Views:
    105
    Gavin Sinclair
    Dec 27, 2003
  4. John Levine
    Replies:
    0
    Views:
    733
    John Levine
    Feb 2, 2012
  5. Unknown Poster

    HTML / text parsing - best module(s) to use?

    Unknown Poster, Jul 29, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    72
    A. Sinan Unur
    Jul 30, 2003
Loading...

Share This Page