Re: fix indentation and find non-ascii

Terry Reedy <[email protected]>
Newsgroups gmane.comp.python.idle
Message-ID <[email protected]>
On 3/28/2014 2:19 AM, Sean Felipe Wolfe wrote:
> Here's the circumstances that brought this up.
>
> I was helping a new programming student walk through some example
> code, having him both type manually as well as copy + paste from the
> site and we would talk it over.
>
> When it came time to run the module, we ran into a few typos, a few
> indentation errors, a capitalization error, no problem, easy fixes.
> But the script kept failing on two points: one, it claimed that we
> were using non-ascii and needed to declare the file as UTF-8.

Since Py3 expects utf-8 by default, were you using 2.x?  If so, I 
recommend you have new students start with the latest 3.x, partly to 
avoid some unicode problems.

 > Two, it continued to say there was an
 > indentation error after we'd checked itclosely.

'It' is Python, not Idle.

> I eventually exported the file to vim, but there were no indentation problems.

This suggest that there was some other syntax-like problem that caused 
the indentation to seem wrong. But I cannot comment without the code.

> What we ended up doing, was to delete the offending line and type it
> manually on a new line.
>
> This ended up being much more complicated than it needed to be,

I have no idea what you mean. Typing a line is pretty simple.

> I think IDLE could add value here by providing convenience features to
> get a script back to a simple state, both by fixing indentation

I do not know what you mean by 'fix' indentation but no code can read 
your mind. In any case, this is not specifically an Idle issue. I 
already agree that we should make it easier to run or create editing 
tools. Perhaps Tools/Scripts/reindent.py will do what you need. That and 
anything like it should be accessible from Idle.

> well as resetting to a dead-simple charset, do deal with things like
> accented characters

These are legal, especially in Python 3. I am willing to highlight, but 
not blindly remove (and see comment below).

> or stylized curly-quotes.

If a site publishes code mangled with substitute chars, you should 
complain to the site. But besides that, the ability to run str.translate 
on editor window text is a plausible idea.

-- 
Terry Jan Reedy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.