List to dict
22/06/2009Nifty one liner.
l = ['a', 10, 'b', 20, 'c', 30]
it = iter(L);
d = dict(zip(it, it))
Useful, inconsequential & random
Nifty one liner.
l = ['a', 10, 'b', 20, 'c', 30]
it = iter(L);
d = dict(zip(it, it))
So are you fed up with the new Facebook layout and the quiz spams. Install:
Nirvana ![]()
So lately for bunch of jobs, I have been required to parse and work with bunch of XML which contains lot of SQLAlchemy serialized values.
After fighting with all the XML based parsers for quite sometime, I finally found xmltramp. A great tutorial is available here.
It simple, concise and does couple of things but in a great way. Really love its XML to Python object translation.
On top of xmltramp, I wrote a simple SQLAlchemy ORM serializer/deserializer. Almost looks like a hack now but it works so I am happy.
http://bitbucket.org/beamtous/sandbox/src/f0301bb4425d/xmltramp/test.py
all(x == L[0] for x in L)
If you love using VIM and want a similar experience in your browser:
Vimperator. They even have muttarator though that only works with Thunderbird 3.0 and above. Will need to play around with that too.
Good to see that some Indian news is making headlines in Reddit.com.
Hopefully, this will generate enough interest in Indian people to show the duplicity and hypocrisy of Indian media.
The following code generates a dictionary of all key/value in a configuration file.
import ConfigParser
config = {}
cp = ConfigParser.ConfigParser()
cp.read('test.cnf')
for section in cp.sections():
config[section] = dict(cp.items(section))
print config['section1']['key1']
In an attempt to have the best programming environment setup, I ordered the Das Keyboard ultimate.

I simply love the mechanical sound it makes.
BTW, VIM+Python rocks ![]()
Soon a post of what I have done to improve my Python coding with VIM.
If you are somebody who spends 12+ hours everyday with VIM and Konsole, you have to use this theme for both.
Are we moving towards a police state?
