[code.view]

[top] / python / PyMOTW / cmd / cmd_argv.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     import cmd
     
     class InteractiveOrCommandLine(cmd.Cmd):
         """Accepts commands via the normal interactive prompt or on the command line."""
     
         def do_greet(self, line):
             print 'hello,', line
         
         def do_EOF(self, line):
             return True
     
     if __name__ == '__main__':
         import sys
         if len(sys.argv) > 1:
             InteractiveOrCommandLine().onecmd(' '.join(sys.argv[1:]))
         else:
             InteractiveOrCommandLine().cmdloop()

[top] / python / PyMOTW / cmd / cmd_argv.py

contact | logmethods.com