Switching keys and values on a Python dictionary

This is a stupid question I asked in the office today: Imagine you have dictionary and you want to build a new dictionary where the keys are the values and the values are the keys.

Gak came with

new_dict = dict(zip(old_dict.values(), old_dict.keys()))

Thinking about it, I came with

new_dict = dict([(old_dict[k], k) for k in old_dict.keys()])

I know that keys will not return a list anymore on Python 3, so I guess my solution is the right one. :)

SVN should NOT be used in large projects

Subversion was created to “fix” the problems with CVS. The problem is that it really didn’t fix them.

The biggest issue with CVS is that it can’t handle banching properly. It takes a lot of space and it freaking slow. SVN does it in a clean way, so branching is way faster and easier. This is good, as branching is one of the ways to keep several developers working in different parts of the system, holding the features till they are stable and working properly, without worrying about conflicts.

SVN problems start when you merge things back. When you merge branches, you became the owner of the changes. Imagine that you are working on a branch while all the other developers are working in the trunk. From time to time, you merge the trunk back into your branch, so things will be easier when merging your branch to trunk. When you finally do, SVN will put all changes in your name. Can imagine being called at two in the morning to fix a problem because the code says you’re then one who did the change, just to get there and see some piece of code that you never EVER saw in your life?

SVN fixed the branching problem, but they forgot that there is merging after that. It is like that joke about a group of programmers that wrote a compression utility that could compress 1mb into 1 byte and now where working on the decompression utility.

You have to hate the media

What a social engineer, the leader of a warez group, a computer scientist who wrote one of the most well-known programming languages and a kid who accidentally writes a script that infects several computers have in common?

They are all called “hackers”.

I’m not kidding here. Twice this week I read some article about “most famous hackers” and the list have all those listed. It seems that they put the “bad guys” in front of the list, to give it a “those guys are bad” feeling about it.

One of the articles had Dennis Ritchie, the guy who designed the C programming language with Ken Thompson; the other had Richard Stallman, the father of the GNU organization and the free software movement. The rest of the guys? One guy who cracked a telephone company, the kid who wrote a computer virus and brought several *cough*windows*cough* machines down. Oh, and Kevin Mitnick.

Planet is misbehaving

For those trying to follow Planet slow, you may have noticed that, for some weird reason, the posts don’t appear in the right time. It seems that Planet tries to put them in chronological order, something that don’t work with all the feeds (because some use UTC and some are using localtime and some don’t put a proper time and keep appearing in the top of the planet all the time, even without updates).

Since Planet is written in Python and it is free software, I’ll try to have a look at it and make it put new posts always in the top, no matter the posting time. And then make a patch. And send it to Jeff Waugh. :-)

And that’s why I love free software.

Helping the slowhome empire grow larger

There are two new additions to my list of sites:

  • slow’s Random Notes: Blogs are not a nice place for content that keeps changing every time, so I decided to add a new site to keep small notes and stuff.
  • Planet slow: aggregation of all my feeds. It’ll make my life easier and also let you know what the fuck I’ve been reading. I still have to check with the Dreamhost guys if that’s alright (but I guess it is).

And yes, I still need to “Pythonize” the templates. :-)

Running playlist

Since I can’t drop out this City2Surf thing (actually, I don’t want to quit) I decided to run using my iPod so I would have something to distract me from the pain. But, most importantly, I need to have a playlist first. I mean, I can’t run hearing “Still Have the Blues” by “Gary Moore” and expect to have that extra energy from the song. So far, the list is really small, but I want to have like 2 hours of music to run. So far, I have:

  • Joe Satriani – Speed of Light
  • Freedom Call – Starlight
  • Twisted Sister – We’re Not Gonna Take It
  • Rush – Limelight (added Jul 03, 09:42)

Suggestions are welcome.