|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Has any of you ever used the cmd module? I read the document at the Python homepage, but I didn't really understand how to use the module. If some could show me some code, I'd really apprieciate it.
__________________
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes! |
|
#2
|
||||
|
||||
|
hope works..
Code:
#!/usr/local/bin/python
import cmd
import mailbox
userbox='/var/mail/jedi'
list=[]
mb=mailbox.UnixMailbox(open(userbox))
class Reader(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = "Reader:"
def help_get(self):
print "Gets all the messages in your mailbox."
def do_get(self):
while 1:
msg = mb.next()
if not msg:
break
msg["body"] = msg.fp.read()
list.append(msg)
def help_quit(self):
print "Quits you out of Reader."
def do_quit(self, line):
print "Exiting..."
sys.exit()
if __name__ == '__main__':
readbox = Reader()
readbox.cmdloop()
Last edited by Gerardoj : November 30th, 2003 at 01:21 AM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > cmd module |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|