Categories
Programming

python list comprehensions, with surprise!

Wasn’t expecting this behavior, but variables used in list comprehensions and with blocks continue to be in scope…

# variables introduced in list comprehensions continue to exist in scope
[a_var for a_var in range(10)]

print "Hey, what's a_var?", a_var

# similar thing happens when using "with"
with open("some_file.txt") as a_file:
    pass

print "Hey, what's a_file?", a_file
python test.py
Hey, what's a_var? 9
Hey, what's a_file? <closed file 'some_file.txt', mode 'r' at 0xb747cee8>
Categories
Programming

git patch mode

A friend at work sent these videos around. If you use git and have ever made more than one feature change in a file between commits, patch mode can help!

http://www.youtube.com/watch?v=Wl0NfWYrvlY

http://www.youtube.com/watch?v=1tqMjJeyKpw