Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 19th, 2003, 03:39 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 5
Question cmd module

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!

Reply With Quote
  #2  
Old November 30th, 2003, 01:17 AM
Gerardoj's Avatar
Gerardoj Gerardoj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128 Gerardoj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 5
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > cmd module


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway