Some recent Google spam problems
With my anti-spam hat on, I'm not a fan of Google. It's not thatthey're active spammers themselves, it's that their services are notinfrequently used to send spam in various ways and Google is famouslyindifferent to it, or at least apparently indifferent, and has beenfor some time .
(I've felt for years that there was basically no point in trying to fileany sort of anti-spam report with Google because it would just go into ablack
Python's attribute lookup order
One of the things that surprised me recently is that the Pythonlanguage reference doesn't seem todocument the specifics of how Python searches for the attribute when youtry to access obj.attr . So here is a not completely formal descriptionof the process for Python 2.7 or so for new-style classes.
(Such a description really belongs in the language reference becauseit's an important part of Python's semantics. It's possible that youcan reassemble a full description of the lookup semantics
An operational explanation of Python types
In the world of new style classes, everything in Python has a type(visible with ' type(thing) '); class instances have a type, classeshave a type , even type() has itself as a type.Sure, fine, but what does it mean in Python to have a type? What dotypes actually do ?
Given part 4 of what you can do with metaclasses ,we can now see the answer: an object's type is where Python findsspecial methods for it .
I've surrendered on utm_* query parameters in URLs
I've written before about the various extrautm_* query parameters that show up on a lot of URLs these days (itturns out that they are apparently due to a Google product calledUrchin ). Back thenI was optimistic that a change in the Planet Sysadmin Twitter feed would make them go away. It turnsout, well, no such luck. These days, all sorts of things 'helpfully'add these query parameters to URLs that are shared through the variousparts of the social web; in
Why I still comment out code even with a VCS
One of the bits of VCS doctrine that I've seen is that once you havea VCS you shouldn't comment out code (or #ifdef it out or theequivalent); instead you should just delete it because you can alwaysget it back from the VCS.
Well, I have a VCS or two and I have to say that I continue to commentout my code for the most pragmatic of reasons: I find it an easier wayto work. In theory the whole idea of using the VCS
An operational explanation of Python metaclasses (part 4)
The metaclass use of __call__ that I covered in part 2 and the use of __getattribute__ et al that Imentioned in part 3 are both specific instances ofa general metaclass power: a metaclass supplies the special methodsfor its classes . However and as before, these special methods applyonly when you are looking at or manipulating the class itself, not whenyou are dealing with instances of the class.
(Special methods for instances of the class have to be supplied bythe class or
An operational explanation of Python metaclasses (part 3)
Following on from part 1 and part 2 , the third thing that we can do with a metaclass isto create 'class-only attributes', attributes that are only visible on theclass and not on instances of the class. In fact we can go further thanjust adding attributes; we can control what attributes are directlyvisible on the class without affecting what attributes are visible oninstances of the class.
Simply adding attributes to the class (and only to the class) isdone by putting attributes on the metaclass
An operational explanation of Python metaclasses (part 2)
After modifying a class as it's being created ( covered in part 1 ), the next thing you can do with a metaclass isget a chance to do things when instances of the class are created.You do this by defining __call__ on your metaclass:
class MiniMeta(type): def __call__(cls, *args, **kwargs): return super(MiniMeta, cls).\ __call__(*args, **kwargs)
Setting the character encoding for HTML form input
Courtesy of reading HOWTO Use UTF-8 Throughout Your Web Stack ,I recently rediscovered the form accept-charset attribute (I say'rediscovered' because I clearly once knew about it since I mentionedit in passing back in 2007 ).
Setting an explicit accept-charset attribute on your forms solves (intheory) one of those niggling little HTML forms questions, that being'what character encoding did the browser use for encoding this text theuser submitted?' As spelled out in the HTML 4.
How your Linux installer should help you set up filesystems
I've said before that Linux installers handlesetting up software RAID exactly backwards, forcing you to go from lowlevel mechanics to high level results. In fact this is a symptom ofa general failure in how most distributions handle partitioning andsetting up filesystems.
The common approach I've seen is to offer you two basic choices: you canaccept a few common variants of a canned filesystem configuration or youcan specify everything from the ground up. If you're setting up softwareRAID, the ground up way