As of late I have been spending some of my spare time (what little there is) on teaching myself Python. Honestly I haven't gotten very far, however, since I always find that the best way to learn something is to use it for a real purpose .... I submit to you the following first real attempt at Python
Need:
Easy way to post interesting links I find on the web to my blog without having to manually enter & copy them from Del.icio.us
Solution:
Python script that takes in the desired Delicious tag and usernames/passwords, retrieves link information from Delicious, creates simple HTML for blog post, and posts new post on Blogger blog. The 1.0 version of the script can be found here. It was written without a good idea of design (general or python) because my goal was to get it working, not make it perfect. Future changes will entail a better interface for doing more than one tag/blog at a time, moving the html template outside of the script, removing the delicious links or at least renaming their tags so that they don't end up sent twice, and some sort of error handling so that if the blog posting fails, I don't lose the links. Despite being some crappy to look at code, it works as can be seen by the previous post on this blog as well as recent ones on my other blogs.
Thoughts:
- Since most of my work has been with Java, trying to not make it Java-esque is hard
- I am still very much figuring out how to best use the dynamic features of the language and how best to "scope" things
- There seem to be libraries out there to do anything you want, but without central places to look for them or consistent documentation, its hard to know whats available and what methods objects have (something similar to javadoc would rock)
- The ElementTree documentation on this site is wrong for Python 2.5+, need to import ElementTree form xml.etree now, not elementtree
- At the moment I have been working on my Mac with IDLE (came with the python version I installed) and it works well enough, but I need to find a better general purpose editor and/or find a good plugin for IntelliJ (great Java IDE and editor)
- Some of the errors you can get by accidentally adding Java-esque syntax to your python script can be very hard to track down ;-)
Here are some more links I found helpful in writing this...
- Delicious API help
- Blogger API help
- Yahoo developers page showing how to retrieve data from a HTTPS connection in Python
- ElementTree documentation
- Dates and Times in python info
- Python -> HTML script
- Scudder's Scorpion Server and related posts
No comments:
Post a Comment