[Tutor] Notepad++ question

Alan Gauld alan.gauld at btinternet.com
Thu Jun 7 09:41:02 CEST 2012


On 07/06/12 05:29, Alexander Quest wrote:
> Hey all; my question is regarding editing Python code in Notepad++. When
> I run this piece of code in Notepad++:
>
> def fix_start(s):
>    var1 = s[0]
>      var2 = "*"
>    var3 = s.replace(var1, var2)
>
>    return var3
>
>
> I get an indentation error, which reads:
>
>
>    File "C:\google-python-exercises\google-python-exercises\basic>string1.py
> line 56
>      var2 = "*"
>      ^
> IndentationError: unexpected indent
>
>
> The thing is that in Notepad++, that code does not appear with an
> indentation where var2 is. It appears like this:


This is almost certainly down to mixing tabs and spaces.
You can mix them in a file but not within a block. (And
even then I would recommend sticking to just one style)
Some editors make it worse by autoindenting with a mixture
of tabs and spaces which is fine for C or Java but no
good for Python... I don't know Notepad++ so can't comment
on it.

> is here? Also, I am wondering why use Notepad++ or other such programs
> when IDLE seems to be fine for writing code. Thanks.

IDLE is fine for beginners. It is less powerful than other
text editors such as vim or emacs or Eclipse or even Scite.
But that power is mainly useful when dealing with multi-file
projects or large files. But IDLE is fine for most Python tasks.
If you are happy with IDLE use IDLE.

Some of the missing features that I like are:
- incremental search
- navigate to a character (t or f)
- rectangular cut n paste
- split screens vertically
- integration with the OS
- goto-function definition
- macros

But editor choice is very personal, some like a simple
editor some like all the bells and whistles possible.
It's up to you. Find one 9or several!) that you like
and use it. But don't let choosing an editor get in the
way of learning Python, they are two separate things.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list