Sunday, November 29, 2009

Scribes - Hacking Python Made Easier



Have you ever been sent a Python script that won't compile? You open the script in your favorite text editor, of course Scribes, and the code looks perfectly crafted. You see no visible syntax or semantic errors. Yet the script won't compile or run! Then you find the problem. Tabs and spaces were simultaneously used for indentation! Python squeals when you do that. The good news is that Scribes provides ways of dealing with this annoyance. As well as other features that make hacking python modules a pleasure with Scribes.





Scribes automatically activates a syntax checker for Python modules. Just press F2 to have Scribes jump to the line that has a syntax error. Keep pressing F2 until all errors are fixed. The status bar message will inform you when no more syntax errors are found. I promise you. This feature will save you heart aches.





Scribes also has functions to convert spaces to tabs and vice versa. Alt+t converts indented spaces to tabs. Alt+Shift+t converts indented tabs to spaces. These functions are life savers when that thing decides to use spaces for indentation. Or it decides to mix spaces and tabs when indenting. Again mixing spaces and tabs for indentation will make Python buck.





Perhaps the easiest, fastest and most effective way of getting rid of indentation problems is showing white spaces. Alt+. does this in Scribes. If you hack code, especially Python code, making Scribes show white spaces is the first thing you should do. I've spotted all indentation errors in Python modules using this feature alone. So turn it on!





I've also blogged about the symbol browser for Python in the past. Pressing F5 activates it. The browsers shows all functions, methods and classes in a python module and allows you to navigate to them quickly. It's considerably efficient compared to scrolling up or down the document. Other goodies include (un)commenting lines (Alt+c) and automatic indentation.





Use Scribes and forget about indentation nightmares and lost productivity. Hacking Python has never been so enjoyable since I started using Scribes. It's also proof you don't need a fancy-pancy-1GB-memory-guzzling-complicated-IDE to hack on Python modules efficiently, effectively and productively. There's always room for more "smarts". So I welcome your ideas.