python to pythoning ……

September 1, 2008

homepage

Its not a dramatic change in me for switching from “Java” to python And i did not. …. well , all i  wanted to have fun coding in python rather than “Java” …. Intially i was totally confused whether i should  learn ruby or groovy or python or whatever that suppose to make me smile while coding…. But i learned python that its one of the more popular , strong ,dynamic bla bla bla …… And i am still a novice , i started with byte of python tutorial which is excellent tutorial by swaroop (http://www.swaroopch.com/byteofpython/) …. Ya just started out with python shell executing all basic stuffs using IDLE … Its amazing thing to learn python .. if you python then surely you will never turn off from your mind … get addicted to it , like i am . Till now i learned so many things that i wouldn’t have learned from any other language … beacause its very simple , ease … and only thing that you have to apply some common sense while pythoning ….

You can write sophisticated taks within in few lines … what you code in java/c++/c can be done within few lines ….. you will more over concentrate on solution to the problem rather than syntax !… And it has got numerious GUI and Web frameworks and its still amazing .

Today i found libgmail.py library , where i can play around with GMAIL account using python…. (http://libgmail.sourceforge.net/)

Which is a Library to provide access to Gmail via Python

After downloading libgmail … all i have to extract to my /lib directory .

some examples i worked out …..

SEND MAIL

import libgmail
import mechanize as ClientCookie

ga = libgmail.GmailAccount(“username@gmail.com”, “password”)
ga.login()
msg = libgmail.GmailComposedMessage(‘to@gmail.com’,’subject’,'body’)
ga.sendMessage(msg)
print ‘\nEmail sent’

READ MAIL

import libgmail
ga = libgmail.GmailAccount(“username@gmail.com”, “password”)
ga.login()
folder = ga.getMessagesByFolder(“inbox”, True)
for thread in folder:
print “Thread:”, thread.id, “Subject:”, thread.subject
for msg in thread:
print “Msg:”, msg.id, “,Author”, msg.author, “,Subject:”, msg.subject

To send attachment files

import libgmail
ga = libgmail.GmailAccount(“username@gmail.com”, “password”)
ga.login()
myFiles = ["/file1", "/file2", "/file3"]
msg=libgmail.GmailComposedMessage(“friend@gmail.com”, “SubjectHere”, “BodyHere”, filenames=myFiles)
ga.sendMessage(msg)

Infact you can read contacts , read trash , read Unread mails etc ……..

Isnt it amazing !! …. poetic way to python ….

Entry Filed under: Python. .

6 Comments Add your own

  • 1. ranganath  |  September 1, 2008 at 11:09 am

    cooll

    Reply
  • 2. Syed Aslam  |  September 2, 2008 at 5:47 am

    Hmm.. nice.. so are you going to shun Java..

    Reply
  • 3. Madhu  |  September 2, 2008 at 6:01 am

    Nope i wont shun java .. there is always a jython when i learn python ….

    Reply
  • 4. Ranganath.S  |  September 3, 2008 at 6:23 am

    well , learning one language doesnt mean u gonna shun other language… its just that u learn different language to get a different perspective of solving the problem thats all. for example currying in python is some thing u cant achieve in java easily. but yep you can achieve it but will be a big run around.

    Reply
  • 5. swamy  |  November 18, 2008 at 11:00 am

    Dear sir,
    i need pop up ballon code could u please send me

    Regards
    Swamy

    Reply
  • 6. madhucm  |  November 18, 2008 at 12:27 pm

    this may be useful
    http://xoomer.alice.it/infinity77/main/freeware.html

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

AD

September 2008
M T W T F S S
« Aug   Nov »
1234567
891011121314
15161718192021
22232425262728
2930  

Archives

1

Blog Stats

Talk To Me

Text