Consider the following three classes, where C inherits from A and B, and the method m() is present in both A and B.
class A(object):
def m(self):
print "a.m"
class B(object):
def m(self):
print "b.m"
class C(A, B):
def test(self):
pass
Now, if you create an instance of class C and invoke method m, what will be the result?
>>> c = C()
>>> c.m()
a.m
The Python docs tutorial on the subject says “the resolution rule used for class attribute references (…) is depth-first, left-to-right.”, which seems like an easy rule. However, it also warns about some maintenance nightmares, e.g “a class derived from two classes that happen to have a common base class”.
After almost two hours of debugging, I finally made an interesting (at least to me) discovery in Python: Attributes of type dictonary and list (and presumably all other object types) at the class level are “static” (as used in Java classes), while primitive types are not. Does that make sense? I don’t know.
Consider the following dummy class:
class MyClass:
e = {"a":None}
f = [0]
i = 50
def __init__(self):
self.d = {"a":None}
def set(self, v):
self.d["a"] = v
self.e["a"] = v
self.f[0] = v
We have four attributes here:
e – a class level dictionary
f – a class level list
i – an int
d – another dictionary referenced by self.d inside the methods.
Now consider the following result from these interactive lines:
>>> x = MyClass()
>>> x.set(5)
>>> x.d
{'a': 5}
>>> x.e
{'a': 5}
>>> x.f
[5]
>>> y = MyClass()
>>> y.set(10)
>>> x.d
{'a': 5}
>>> x.e
{'a': 10}
>>> x.f
[10]
>>>
>>> y.i = 100
>>> x.i
50
>>> y.i
100
>>>
As you can see, the first call to set method, set the value 5 in x.e, x.f and x.d. However, the second call, y.set(10), will also set the value of x.e and x.f (in red). Finally, it is shown that the int i does not conform to this behaviour.
Strange, I say.
The American oil company Exxon has put out two hysterically funny ads to fight the “CO2 equals global warming” argument. The scary part is that they are dead serious. Or as others comment: “We can’t parody this, because it’s already a parody.”
Watch for yourself here: http://streams.cei.org/
Gates recently had to defend his PC component based model, and claims that it is far from over. Here is jkrise’s take on the issue:
The PC era can be declared over, if and when:
1. Windows Vista – Service Pack 2 is released.
2. Microsoft releases a complete OS under “GPL 3.0 or later”.
3. Software patents are declared illegal in the US.
4. Chinese firm releases complete PC – hardware and software, fully developed and built in-house – at under $100.
5. SCO defeats IBM and buys RedHat.
6. nVidia releases GPL drivers.
7. Symantec withdraws from security market, declaring Vista is ‘unbreakable’.
8. DRM is declared illegal, DMCA revoked, and the RIAA dissolved.
9. Hurd 1.0 is available for download.
10. No more chairs in the Chair-Man’s Office at Redmond.
http://it.slashdot.org/comments.pl?sid=185951&cid=15348273
“This movie was built with data collected during the 147-minute plunge through Titan’s thick orange-brown atmosphere to a soft sandy riverbed by the European Space Agency’s Huygens Descent Imager/Spectral Radiometer on Jan. 14, 2005.”
NASA article
Although just a computer animation, it is based on the actual data from the radiometer. If you have time, download this high resolution version of the movie [91 MB] instead. It is rather impressive.
“It recently came out that the firewall in Microsoft Vista will ship with half its protections turned off. Microsoft claims that large enterprise users demanded this default configuration, but that makes no sense. It’s far more likely that Microsoft just doesn’t want adware — and DRM spyware — blocked by default.”
(…)
“You can fight back against this trend by only using software that respects your boundaries. Boycott companies that don’t honestly serve their customers, that don’t disclose their alliances, that treat users like marketing assets. Use open-source software — software created and owned by users, with no hidden agendas, no secret alliances and no back-room marketing deals.
Just because computers were a liberating force in the past doesn’t mean they will be in the future. There is enormous political and economic power behind the idea that you shouldn’t truly own your computer or your software, despite having paid for it.”
by Bruce Schneier
http://www.schneier.com/cgi-bin/mt/mt-tb.cgi/866
Just installed Fedora 5 and lost my Alt+Tab keybinding. This finally got it back:
gconftool-2 --type=string --set /apps/metacity/global_keybindings/switch_windows '<Alt>Tab'
For more, see these notes:
http://www.gungeralv.org/notes/archives/000323.php