Well I've been reading this book called "head first beginning programming" so I can learn Python without all the bloat of normal Python books. I modified a function that they used to accept your username and password as parameters. I might add string length checking to so that you dont get errors for the message being to long.
Code: Python
# includes start
import urllib.request
#includes end
def sendTwitterUpdate(msg,twitUserName,twitPassword):
passManager = urllib.request.HTTPPasswordMgr()
passManager.add_password("Twitter API","http://twitter.com/statuses",twitUserName,twitPassword)
httpHandle = urllib.request.HTTPBasicAuthHandler(passManager)
pageOpener = urllib.request.build_opener(httpHandle)
urllib.request.install_opener(pageOpener)
params = urllib.parse.urlencode({'status': msg})
response = urllib.request.urlopen("http://twitter.com/statuses/update.json", params)
response.read()