Categories
Programming Text Editing

Sublime Text Paragraph Re-Wrapping

I’m a big fan of sublime text and just found a great function for re-wrapping text. In Debian, select the block of text to re-wrap and hit alt-q (shortcut for Edit > Wrap > Wrap Paragraph at Ruler).

That will take you from this:

no_respect_for_ruler

To this:

alt_q_rewrap

No more manual formatting, woo!

Categories
Life Photos Programming

Converting from Python 2 to 3

"You too can solder!"
“You too can solder!”

And here’s a clip I took a while back too: Crissy Field, SF CA

I found a hierarchical tagging Django app called django-categories that I wanted to use in a project. There were a couple of things that I wanted to fix so I forked it and for one reason or another started to build in Python 3 support.

I’ve heard about Python 3. I’ve even written some small programs in it. But library support wasn’t really there back when I tried it and I slunk back to the comfort of Python 2.7. It turns out that all the dependencies for django-categories work in Python 3 and I found a few tools that make version portable code a snap to write. Maybe 2014 is the year of py3k.

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>