Category:Python

From Noah.org
Revision as of 14:56, 7 December 2007 by Root (Talk | contribs) ([http://www.noah.org/engineering/dotfiles/.vimrc .vimrc] for Python)

Jump to: navigation, search

Python.png

Pexpect

I loved Expect, but I hated TCL, so I wrote this 100% pure Python module that does the same thing. Click here for more details:

Pexpect -- An Expect-like module in pure Python

Free Python software

You can find other free software I wrote (mostly in Python) here: Free Software

.vimrc for Python

I like Vim. This is how I set my .vimrc file.

This add sensible tab settings for Python. It also defines simple folding. I never liked the built-in indent folding for Python because it folds too much -- every indent becomes a fold! For code folding I just want to see class names and method names. I don't need every single nested loop folded many levels deep... In this .vimrc see the section on "folding using /search/ pattern". This maps the normal mode key sequence, 'zff' to set the search pattern to find all class and method names. This also maps '\z' to refold every search pattern. The neat thing is that this pattern also works on PHP code! The '\z' mapping is also handy for editing other documents.

Python Cookbook

I have a few recipes on ActiveState's fun and useful Python cookbook.

WTF?

This will test for primality with a regular expression. No, I'm serious...

    import re
    def is_prime (num):
        return re.match(r"^1?$|^(11+?)\1+$",'1'*num) is None