Hey, I'm new to python so don't judge.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jan 4 21:51:41 EST 2017


On Thursday 05 January 2017 10:21, Terry Reedy wrote:

> On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote:
> 
>> And that statement tells us you are trying to run from within some
>> IDE/editor which is trapping Python exceptions and producing a dialog
>> box for them.
> 
> IDLE does this when one runs code from the editor, because it
> cannot/should not inject error messages into the editor buffer...
> AND it replaces the ^ with red highlighting of the code pointed to.  No
> information is lost.  Apparently, some beginners do not see the
> connection between the SyntaxError box and the red highlighting.

Some people may not even be able to distinguish red from other colours. Those 
with red-green colourblindness will probably see the red as a sort of muddy 
brown that hardly stands out as different from usual black text.

http://wearecolorblind.com/

One should never use colour alone as the only indicator of status.

http://stackoverflow.com/questions/1498669/gui-design-for-color-blindness

http://davemeeker.com/color-blind-considerations-for-ui-design/


> I
> think I should add something to the box.  Maybe 'The error was detected
> at the point of the red highlighting.'


I just tested the REPL in idle for 2.7.4, and I get this:

>>> print Hello World
SyntaxError: invalid syntax


where "print" is green text on a white background, and "World" is black text on 
a red background. That may be unfriendly to the colourblind, and makes coping 
and pasting the error less helpful. I suggest:

- check the colours in a colourblindness simulator, and pay attention to the 
contrast; is the text still clear?

- include the ^ caret as the primary status indicator, delegating colour to 
secondary; this makes errors in IDLE a little more like the same experience in 
the standard REPL.


If I open a Python file containing:

print Hello World

and choose "Check Module", IDLE highlights the word "World" in red and displays 
a dialog showing:

There's an error in your program:
invalid syntax

Suggestion:

Change the dialog box to display a read-only text field showing the traceback:

  File "idletest.py", line 1
    print Hello World
                    ^
SyntaxError: invalid syntax


and add a button "Copy traceback" to allow the user to copy the text of the 
traceback and paste it into an email.

(Strictly speaking, the Copy button is redundant if the user can select the 
text in the field, but beginners may not realise the text can be selected.)



>> Instead, save your script (if you haven't yet) as a file
>> (whatever.py).
>>
>> Open a command line interpreter/shell.
>>
>> Navigate (cd ...) to where you saved the file
>>
>> Type "python whatever.py"
> 
> What a nuisance.

*shrug* If you're a Linux user, chances are you already have a shell open and 
ready to go. And with tab completion, you don't have to type as much as you 
might think. It just becomes second nature after a while.

I type something like "py<TAB>path<TAB>what<TAB><ENTER>" and the shell will 
autocomplete directory and filenames.

Anyway, this isn't an argument over which is better, IDLE or the system 
terminal. They both have their advantages and disadvantages, and in practice 
the real answer to "which is better?" is always "whichever one you are used 
to".



-- 
Steven
"Ever since I learned about confirmation bias, I've been seeing 
it everywhere." - Jon Ronson



More information about the Python-list mailing list