Stop beating your wife
3 months ago
/homepartition, so all my settings, e-mails, documents, work is saved (I still do backups, just in case). Installing was a breeze (as always with Ubuntu), so here are my impressions (it's already been about two weeks since I updated), I'll start with the good ones. Boot time -- definitely improved. I had little faith in this as I saw it being advertised everywhere, but it seems that they have done quite a good job. My system definitely boots faster now (although I have yet to install additional startup software, like Apache, MySQL, VirtualBox, and the like). My bluetooth dongle is working again -- yay! The previous release had some buggy kernel module which rendered my dongle useless, but it seems it has been fixed. Finally, I can send stuff to my mobile phone without having to connect it via USB. Well, it still doesn't work perfectly, for example I can't send files from my phone to my PC, but otherwise everything works (even browsing the contents of the mobile phone on my PC). The new notifications are pretty cool, but only if you use a compositor, which I don't generally use. If you don't use a compositor, they suck. Thus, I have enabled metacity compositing (so I don't have to run Compiz). Ok, now with the bad ones: first off, what's with THE PINK!? Seriously, way too much pink in the new theme. I think that the 8.04 theme was the best (I love orange and brown). This theme is way too pink! Here's Transmission with no torrents: What the hell? That's so wrong. Anyway, on to the other bad things. For some reason, it seems Ubuntu uses more RAM than before, and I only have 512MB, which makes it constantly use 2-300MB swap, and that really overwhelms my hard drive. It may be because it's the first time I've installed the 64bit version (which uses a bit more RAM by definition, because memory pointers are twice as big). I've been having this PC for two years and a bit and I just found out a month ago it has a 64bit CPU :-\. Other than that, no huge improvement. Finally having Python 2.6 is pretty cool, it has some nice new features (like the json module). I'm waiting for a more substantial (and hopefully good looking) update with Karmic, although I might just switch to Archlinux in the mean time. 2) The Server Upgrading the server was a breeze. No conflicts, no problems, nothing. Smoo-ooth. Everything just works like before, I didn't need to change a thing -- Apache, MySQL, PHP, all functional. I didn't even have to change my small WSGI app, it just worked. All I had to do was just answer with "no" to all the "do you want me to overwrite this configuration file for you?" questions. Cool :)
duration(seconds). The configuration dialog:
from_xml. These will be @classmethods. From what I understand (I'm still quite new at Python), classmethods are somewhere between instance methods and static functions. The main difference between a class method and an instance method is the fact that the class method receives, as a first argument, the class itself, not an instance of it. Static methods don't receive a special first argument at all. Okay! Let's get to the code:
class MyClass: @classmethod def from_json(cls, json_string): obj = cls() obj.created_from = 'json' # Do stuff, parse json_string, set attributes on obj, etc return obj @classmethod def from_xml(cls, xml_string): obj = cls() obj.created_from = 'xml' # Do stuff, parse xml_string, set attributes on obj, etc return obj def get_create_method(self): return self.created_fromWe have our two initializers. Here's some example usage:
instance_one = MyClass.from_json(json_string) print instance_one.get_create_method() # 'json' instance_two = MyClass.from_xml(xml_string) print instance_two.get_create_method() # 'xml'Sure, classmethods aren't used solely for multiple initializers, but it's one of the most useful things you can do with them.