The assignment was
1 from cmd2 import Cmd 2 from getpass import getuser 3 from sharevalue import share 4 5 __version__ = '0.1' 6 7 class Application(Cmd): 8 """ 9 The main Application class 10 11 """ 12 13 def __init__(self): 14 Cmd.__init__(self) 15 16 def do_hello(self, line): 17 print "Hello:", line 18 19 def do_sayit(self, line): 20 print "Python Rocks!" 21 22 def do_greet(self, line): 23 print "Hi! %s" %(getuser()) 24 25 def do_stock(self, line): 26 share(line) 27 28 if __name__ == '__main__': 29 app = Application() 30 app.cmdloop()
Run the above script like:
$ python psh.py
Here example output is given below:
(Cmd) (virt0)sudip@sudip-mint virtual $ python psh.py (Cmd) stock GOOG Fetching recent share value of GOOG Current share price of company GOOG: 915.60 (Cmd) (virt0)sudip@sudip-mint virtual $ python psh.py (Cmd) greet Hi! sudip