Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm trying to understand just exactly how to use the cmd module

Tags:

python

module

cmd

Let me preface this by saying: I'm a neophyte to Pyhon! I've written a bunch of modules to drive a user interactive application via the command line. Additionally, someone recommended that I look at using the cmd module. And I've looked at it on some sites, but still not sure how to use it. I don't have dyslexia or anything like that, but I have a really tough time digesting technical literature (with no examples) ... I'm a visual learner, and if I can see a good, clear example one time, it's with me for a life time. Can anyone give me a short intro on how to use the cmd module ...? Until then, I will continue to scour Google for good examples. I might get lucky ... Thanks!

like image 916
suffa Avatar asked Dec 22 '22 15:12

suffa


2 Answers

Doug Hellmann's Python Module of the Week series has a good example of using the cmd module.
Another good example is the ActiveState recipe "Console built with Cmd object", but I think it is more complicated. ActiveState Python recipes and PyMOTW are good sources for python examples.

You could also see the cmd module's source to understand how it works, and you may like the cmd2 module too.

like image 177
Artur Gaspar Avatar answered Dec 31 '22 14:12

Artur Gaspar


There was a very nice presentation by Catherine Devlin at last years PyCon about getting started with cmd and cmd2.

Video can be found on pyvideo.

Video, code and slides used to be on the Pycon website but that link is now dead.

like image 29
oivvio Avatar answered Dec 31 '22 15:12

oivvio