Note that there are some explanatory texts on larger screens.

plurals
  1. POPython cmd interpreter adding if statements
    primarykey
    data
    text
    <p>For one of my projects I have a python program built around the python <a href="http://docs.python.org/library/cmd.html" rel="nofollow">cmd</a> class. This allowed me to craft a mini language around sql statements that I was sending to a database. Besides making it far easier to connect with python, I could do things that sql can't do. This was very important for several projects. However, I now need to add in if blocks for greater control flow.</p> <p>My current thinking is that I will just add two new commands to the language, IF and END. These set a variable which determines whether or not to skip a line. I would like to know if anyone else has done this with the cmd module, and if so, is there a standard method I'm missing? Google doesn't seem to reveal anything, and the cmd docs don't reveal anything either.</p> <p>For an idea that's similar to what I'm doing, go <a href="http://blog.fogcreek.com/cheeky-python-a-redis-cli/" rel="nofollow">here</a>. Questions and comments welcome. :)</p> <p>Hmm, a little more complicated than what I was thinking, though having python syntax would be nice. I debated building a mini language for quite some time before I finally did it. The problem primarily comes in from the external limitations. I have a bunch of "data", which is being generous, to turn into sql. This is based on other "data" that won't pass through. It's also unique to each specific "version" of the problem. Doing straight data to sql would have been my first inclination, but was not practical. </p> <p>For the curious, I spent a great deal of time going over the mini languages chapter in the art of unix programming, found <a href="http://www.catb.org/~esr/writings/taoup/html/minilanguageschapter.html" rel="nofollow">here</a>.</p> <p>If I had built the thing in pure python, I wouldn't have had the flexibility I absolutely needed for the problem set.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload