The random musings of a bipolar Linux fan

Friday, June 30, 2006

Was he really having that much trouble?

My sister's boyfriend has been working for weeks on building a simple subnet calculator, and yesterday I told him I'd have a go - if I managed then I could give him a few hints.


Anyway, I did it in a couple of hours (using Glade and Python). I'm not sure if I should let him see the code though (it's really terribly done, although I'm sort of wanting to see if he can decipher lines like:


widgets['netmaskentry1'].set_text(str(netmask >> 24))


widgets['netmaskentry2'].set_text(str((netmask - ((netmask >> 24) << 24)) >> 16))


widgets['netmaskentry3'].set_text(str((netmask - ((netmask >> 16) << 16)) >> 8))


widgets['netmaskentry4'].set_text(str(netmask - ((netmask >> 8) << 8)))


(there's got to be a better way to extract 4 8-bit numbers from a 32 bit one than this :)


0 Comments:

Post a Comment

<< Home