12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

class MySubGui(MyGui):colors = ['black', 'purple']# Customize to change color choicesMyGui(Tk( ), 'main')MyGui(Toplevel( ))MySubGui(Toplevel( ))mainloop( )# Email inbox scanning and maintenance utility"""scan pop email box, fetching just headers, allowingdeletions without downloading the complete message"""import poplib, getpass, sysmailserver = 'your pop email server name here'# pop.rmi.netmailuser = 'your pop email user name here' # brianmailpasswd = getpass.getpass('Password for %s?' % mailserver)print 'Connecting...'server = poplib.POP3(mailserver)server.user(mailuser)server.pass_(mailpasswd)try:print server.getwelcome( )msgCount, mboxSize = server.stat( )print 'There are', msgCount, 'mail messages, size ', mboxSizemsginfo = server.list( )print msginfofor i in range(msgCount):msgnum = i+1msgsize = msginfo[1][i].split( )[1]resp, hdrlines, octets = server.top(msgnum, 0) # Get hdrs onlyprint '-'*80print '[%d: octets=%d, size=%s]' % (msgnum, octets, msgsize)for line in hdrlines: print lineif raw_input('Print?') in ['y', 'Y']:for line in server.retr(msgnum)[1]: print line # Get whole msgif raw_input('Delete?') in ['y', 'Y']:print 'deleting'server.dele(msgnum)# Delete on srvrelse:print 'skipping'finally:server.quit( )# Make sure we unlock mboxraw_input('Bye.')# Keep window up on windows678 | Appendix B: Solutions to End-of-Part Exercises

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!