root/cly/trunk/doc/tutorial/tutorial3.py

Revision 529, 279 bytes (checked in by athomas, 8 months ago)

cly: Update tutorial to reflect 1.0 API changes.

Line 
1 import os
2 import sys
3 from cly import *
4
5 def do_quit():
6     sys.exit(0)
7
8 def do_cat(file):
9     print 'moo'
10     print open(os.path.expanduser(file)).read()
11
12 grammar = XMLGrammar('tutorial3.xml')
13 interact(grammar, user_context={
14     'do_cat': do_cat,
15     'do_quit': do_quit,
16     })
Note: See TracBrowser for help on using the browser.