July 2, 2007
Decorators in Python
Just a quickie - for my archive - Decorators in Python

| Online Casinos - A guide to the best online casinos, gambling sites and casino bonuses |

TurboGears is one thing that fascinates me! So besides reading the Gnome 2 book, this one is right on target! …only problem being, there’s no Indian Edition (Low priced edition) for this book yet. So, ‘am trying to list my other options - buy a used one from Amazon - which would cost me USD 21 (~= INR 1k) or buy it from a local reseller - the international edition is priced about INR 2.1k.
I think i’ll go with the Amazon option if I find no other way out
PS: If anyone has this book as a spare copy, maybe I can buy it as a secondhand. Anyone interested?
Revise your knowledge about Python Types and Objects
For example (straight from the document)
obj = object()
cobj = C()
mylist = [1,2,3]
is related to “type” and “object” as

Fetching a scrapbook page & parsing it everytime to get new messages seems kinda overkill… specially because of the following two reasons -
1) I’m interested in only the new message
2) Parsing HTML which is not controlled by you & which changes frequently can leave your application a bit shaky!
So this is what i figured out when I was SMS’ing a friend during a power cut…
I can diff the new copy of the scrapbook with an old cached copy & parse the diff for only the new message’s html (text/links/images etc).
This will give me 2 benefits…
1) I’m no more dependent on full page’s structure
2) Minimal HTML parsing
BTW… a quick google search showed that my dear Python already has a diffing module up its sleeve - difflib & diffing can be done like this.
Neat… aint it?
Py rocks!
Umm.. this is what I thought I’d name it
Yesternight, I was reading Text Processing in Python, when I wandered off to a section which talked of some HTML parsing. It immediately caught my attention because previously also I was trying to scrap html from my orkut account.
A quick reading & I was ready to go… found my saved orkut’s scrapbook page & started parsing.
What I’m planning is to build a Gnome applet, which would give you a popup when someone posts a scrap on your orkut account will let you reply through the same popup.
But the challenge is… how to knwow that when is a new scrap posted!
The one solution, that hit me instantly was… to keep on fetching orkut’s scrapbook page at regular intervals. To prevent processing every time, I plan to process the newly fetched page only when the MD5 differs
& to take it a step further, a server can be implemented, which can let users query their orkut account via an xml-rpc interface… okay, that’s a bit long shot
Imagine, how nice it would be if people could build third party apps for Orkut
Previous works in this category… http://snipurl.com/wcmm
BTW, another news… I’ve added a new subdomain to makuchaku.info. http://makulabs.makuchaku.info is my new placeholder for all my devel projects/docs/etc. I’ll slowly be moving my stuff there
This name “makulabs” was first suggested by आशीष शुक्ला alias “Wah Java !!”. Thanks आशीष

I spent few minutes on understanding the problem mentioned here
The bug is filed here
This was my first attempt at the bug…
run python, run the interacive shell
import appuifw as a
import series60_console as s
a.app.body = s.Console()
s.app.body.clear()
Then it struck me, why not add this functionality in the menu? Why type all this (or even s.app.body.clear()) when i need to clear the screen… when I can do it fromt he menu itself.
Result… this patch

PyS60 now showing the option to clear screen.
How to use the new console?
A) Copy the interactive_console.py file from c:\resources to c:\python. This needs to be done because files inside c:\resources are read-only… some symbian 3rd edition restriction crap! Refer to release notes & readme for more on this.
B) Either use the patch to patch interactive_console.py or make the changes yourself. Copy of the edited file is here
C) Run python interpreter on your phone, select run script & run the script you just edited/created in step (B)
Text Editors you can use - myeditor_mod (i used this one), more at isiam.blogspot.com and maybe EasyEdit (Not tried it on E61)
Please file your comments/etc in the bug report.
Note - This is my personal work & I take no responsibility of whatever it might break. PyS60 or Nokia cannot be held responsible for after-effects of this patch.
![]()
Happy hacking!
If you are in a similar urgent need to pump all your pics to an online gallery which provides decent space & xml-rpc api, try my ZoLoader script.
Its a very crude script as of now… but is expected to improve with time.
Expected output…
/home/majain/personal/pics/makuchaku.info/Home/Even i can use PC.jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Sleeping beauties.jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Image(313).jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Image(374).jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Me 2.jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Image(474).jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Image(468).jpg file uploaded
/home/majain/personal/pics/makuchaku.info/Home/Sone de naa.jpg file uploaded
….
[update]
This script will crash if it finds two similar images
[/update]
I was thinking of doing this from quite some time, but was searching for the required xml parser. The pyexpat module available from PDIS made for the missing link. I installed the SIS installer available from PDIS website, copied the xmlrpclib.py (from python 2.2.3 source tarball) file to my Nokia 6600 to E:\System\Libs folder & that was it. The “import pyexpat” worked just fine, giving me more confidence to try “import xmlrpclib”… & my 6600 didn’t made me look bad
>>> server_url = ‘http://xmlrpc-c.sourceforge.net/api/sample.php’
>>> server = xmlrpclib.Server(server_url)
>>> result = server.sample.sumAndDifference(5, 3)
>>> print result
{’sum’: 8, ‘difference’: 2}
& the results were worth the effort!
This finding will add more live’liness to apps i’ve planned for flickr & youtube!
[update]
As pointed by Simo [ssalmine-AT-gmail-DOT-com], another XML parser can be found at http://discussion.forum.nokia.com/forum/showthread.php?t=76028
Wow!
I just happened to stumble upon this pluign for Python Development for Eclipse. BTW this is by default there in FC5 & features some nice capabilities like code completition, auto-formatting, support for jython, smart indentation, etc.
A full list is here at the PyDev website.
& for the lazy ones, let the screenshots do the talking
I just love its code completition capabilities ![]()
Had my good night sleep from 10 AM to 4 PM when Manuj landed up
& had brought his Sony Erics 550i walkman phone, which had an amazing voice quality. The UI was nice, but no match for a Symbian UI. Also the lack of apps/games & developer initiative behind its proprietary OS made my Nokia 6600 a much prefered choice. Atleast my Nokia runs Python/C++/Perl
& then something very interesting happened. Manav showed up & was expecting an interview call for a Tech Lead position in GE & was searching for someone who could attend the interview in his place. As Manuj was more than well versed with PC hardware, he was the obvious choice. The interview went so well (with obviously, we narrating everything about Manav to Manuj via a paper/pencil & Manuj reading it out to the interviewer) that Manav got a call in the evening from the GE HR & is now looking forward to lay his hands on the offer asap
What an interview it was! & equally amazing was the way “WE” gave it
Next was the time a Pizza & some snacks! Had an awesome grilled sandwich & ice cream shake,
which proved to be too heavy for my stomach! I had a small stomach ache later on which is still there
Then software & data was to exchange hands… yes, me, manuj & sandy are software smugglers… hahahaha ![]()
Manuj copied some Hindi movies, games & some songs ;-P
Oh, that reminds me of my song collection being too outdated. I need to get hold of sandy some day soon
Then it was about 9 when we “packed” Manuj back home
via ‘bhatinda’… hahahahahaha
A nice day it was ![]()
A very “neat” presentation development app in pypy. I’ll try to make a demo profile for myself using this. The best part is, users can navigate to next slides using a space-bar press.
Have a look at http://www.chrisarndt.de/en/software/pylize/
![]()
I quote a mail from one of the developers from www.youtube.com… They proved to be extremely helpfull & fast in responding to my query. I hope this mail will help all noobs like me ;-P
Hi,
To call the API functions through Python’s XML-RPC interface, you need to pass in a dictionary that holds all the parameters. The dictionary needs to contain an entry for each parameter specified in the API reference. servers.youtube.users.get_profile requires two parameters, dev_id (your developer id, which can be found in your profile
http://www.youtube.com/my_profile_dev.php) and the user that you want to retrieve the profile for.Here’s an example:
>>> import xmlrpclib
>>> server = xmlrpclib.Server(”http://www.youtube.com/api2_xmlrpc”)
>>> server.youtube.users.get_profile({ “dev_id” : “your-dev-id”, “user” : “makuchaku” })…..
Please let me know if this helps.
Cuong
& you can find a very simple example of how to create an XML-RPC server in python, HERE.