Tuesday, May 24, 2011

Tuesday Tips


Watch Your Whitespace

is today's tip. And a very important one when using Python script.

When I first started playing with scripts, I couldn't figure out why I was having a problem. When adding a simple loop in the code, I suddenly had a lot of error messages. But when I looked at my script, I couldn't see anything wrong. Eventually, I read that Python didn't handle mixed white space well. You can use either spaces or tabs for indentation, but beware mixing them.

I learned about using a Python-aware editor. That solved a lot of problems, particularly on scripts that I recorded and edited. But when I tried to modify a script that I hadn't created, I frequently got errors again. Since I didn't have any control over which editor other folks used in their scripts, I was puzzled as how to solve this problem.

Then I found an easy to use text editor that can take a script with mixed white space and correct it. With one easy command. And it's not an editor that is exclusive for Python. It provides color-coded syntax for HTML, Javascript, Perl, ASP, PHP and many other languages.

If you'd like to know Where in the World Wide Web I found this editor, just check back tomorrow. Did I mention that it's free?
Linda

0 comments:

Post a Comment