Pages

2011-04-27

Python's "private name mangling" uncoolness

This:

def __h0la():
print("H0la")

class Foo:
def blah(self):
__h0la()

f = Foo()
f.blah()


throws:

joe@lark:~/sandbox/python$ python pvt.py 
Traceback (most recent call last):
File "pvt.py", line 10, in
f.blah()
File "pvt.py", line 7, in blah
__h0la()
NameError: global name '_Foo__h0la' is not defined


And this explains the behaviour:
Private name mangling: When an identifier that textually occurs in a class definition begins with two or more underscore characters and does not end in two or more underscores, it is considered a private name of that class. Private names are..


The word "TEXTUALLY", is important here. Basically if there is an "__X" occurring within a class definition, immaterial of it referring to something else out side the class, it is 'name mangled'.

I dont know about you, but my stomach does not feel THAT good. :-/

2011-04-16

That piece of shit called "an iPod"..

So, I promised some music to a friend who does not have access to a computer. I had assumed that copying the music onto her iPod should be the easiest way to do it. It turned out to be NOT. Sigh!

To start with, the "iPod Touch 4Gen" wont work with "rhythmbox, gtkpod, libgpod and family", yet. Apparently, Apple is trying every trick they know to keep third-party applications from talking to their device.

Resorted to installing iTunes for windows on a Virtualbox environment. iTunes insisted on downloading album art and junk when it is importing the music. For some reason, it was taking too much time. And to top it, the application was getting unresponsive for every album art it was trying download/analyse/whatever. Hoping to stop iTunes from wasting time, I disabled the network connection. iTunes still spent the same time "analyzing album art" :-/ This time, the CPU was peaking in full load and the application was still unresponsive. Figured that, the only way I can get this done with is, to let iTunes do its shit in its own sweet fcking time. And so, I let it be.

Finally when iTunes was done with its crap, I plug the iPod in and everything was detected fine. The iPod already has 4GB+ music on it and iTunes shows it. But, iTunes refused to add new music to it. iTunes insists that it will delete all the existing music and copy the new music into the device. WTF. Adding new files into the device and updating a database, is not rocket-science.

What I seriously dont understand is, how do people put up with this piece of crap?