Posts Tagged by Python
|12-Feb-2013||Posted by Sonia Hamilton under Golang, Perl, Python, Ruby, Vim|
I’ve just finished refactoring a large Go program, and the process was rather…. pleasant.
Static typing catches all those obscure errors I wouldn’t think about in a scripting language (Python, Perl, Ruby, etc). My process is:
- type :make in vim (I have a dummy Makefile in my Go project just for vim)
- vim jumps cursor to error (vim quickfix list)
- “oh, I shouldn’t do that” – fix (type type type)
- start again
Finish rather sooner than expected, run tests, smile in knowledge program is working properly.
To quickly setup the make command for Go, type this in a Vim window:
:setlocal makeprg=go\ build\ \.
Or even better configure vim via your ~/.vimrc, for example:
autocmd BufRead *_test.go setlocal makeprg=go\ test\ \. autocmd BufRead *.go setlocal makeprg=go\ test\ \./..
Thanks Martin for the comment!
|13-Jun-2012||Posted by Sonia Hamilton under Git, Python|
My new favourite git option:
% git diff -w
Ignore white space in diffs. Unfortunately, there doesn’t seem to be an option for just ignoring whitespace changes at the start of line – would be handy for Python.
|20-Mar-2012||Posted by Sonia Hamilton under Lisp, Python, Ruby|
Up late tonight reading about Emacs Lisp, I came across Tour de Babel by Steve Yegge comparing different languages (C, C++, Java, etc), and why he likes Lisp and Ruby so much. I’m stuck in stodgy Python land at the moment, this is balm for the soul:
Anyway, Ruby stole everything good from Perl; … for the most part, Ruby took Perl’s string processing and Unix integration as-is, meaning the syntax is identical, and so right there, before anything else happens, you already have the Best of Perl. And that’s a great start, especially if you don’t take the Rest of Perl.
But then Matz took the best of list processing from Lisp, and the best of OO from Smalltalk and other languages, and the best of iterators from CLU, and pretty much the best of everything from everyone. And he somehow made it all work together so well that you don’t even notice that it has all that stuff.
|11-Apr-2011||Posted by Sonia Hamilton under Python|
A nice tool written by Jeremy Visser – Python-iView.
As Jeremy says on his blog: “Python-iView is an alternative frontend to ABC iView, which … is an awesome ABC TV programme catchup service that lets you watch most ABC programs from the last month in your browser… However, the iView website has some major problems… To address this, I wrote the open source (GPLv3) application Python-iView, which … allows you to download episodes to your hard drive in their original FLV format.”
|05-Apr-2011||Posted by Sonia Hamilton under Lisp, Python, Slug|
(apologies to slug planeteers for the duplicate info).
A very interesting post from André Pang about some issues he came across with lamdas and closures in Python. Well, interesting to me because I’m playing with Lisp and Python at the moment…
Some links from his blog, in case the original post ever disappears:
- the question and responses on stackoverflow
- an example of the perils of Python’s scoping rules with for/while/if
- Wikipedia – differences in semantics of closures
A nice snippet of code to remind me of the issues:
def callback(msg): print msg funcList= for m in ('do', 're', 'mi'): # funcList.append(lambda: callback(m)) funcList.append(lambda m=m: callback(m)) for f in funcList: f()