Run Windows commands from Python console

Rick Johnson rantingrickjohnson at gmail.com
Mon Sep 4 17:50:41 EDT 2017


Terry Reedy wrote:

[...]

> In IDLE, trackbacks *do* include source lines.
>
>  >>> def f():
> 	return 1/0
>
>  >>> f()
> Traceback (most recent call last):
>    File "<pyshell#2>", line 1, in <module>
>      f()
>    File "<pyshell#1>", line 2, in f
>      return 1/0
> ZeroDivisionError: division by zero

One of the few things that IDLE did better than Python,
which is much more informative than:

> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "<stdin>", line 2, in f
> ZeroDivisionError: division by zero

I think newbies would find IDLE's explicit messaging to be
more intuitive compared to standard Python. Counting lines
is never any fun, and even if you're only dealing with a
few, it's both annoying and inefficient.

When i'm away from an editor (like IDLE, for instance), one
of the features i miss most is the ability to right click
the line of the exception message (you know, the one that
includes the offending line number and offending script
filepath), and choose "open script for editing" from a
contextual menu, which will open the script and
automatically scroll down to the offending line for me.
Ahhh, efficient bliss. OTOH, without such a feature, the
agonising work-flow goes something like this:

(STEP 0): Scan the exception dump for the offending
filepath...

Okay, got it! Now,

(STEP 1) Locate the offending script in the file system...
    
Superficially, such a task seems easy, but if the script is
located deep in the abyssal plane of your file system,
you'll be typing or clicking for what seems like an eternity
to get there... (seconds tick away as rick rapid fires his
way through a mountain of nested data structures with the
exuberance of a world class X-Box champion gamer (and
thankfully for rick, harddrives, like the Universe, are
finite spaces!))... Okay, got it! Now,

(STEP 2) Open the script for editing...  
    
This is not too difficult, but once you've got the script
loaded into an editor, you quickly realize that -- RATS! --
in the process of locating the offending _script_ you've
forgotten the number of the offending _line_. So alas, you
go back to the console window and eyeball parse the
exception dump (again!) until you find the offending line
number... (a few seconds passes whilst rick speed reads)...
Okay, got it! now,

(STEP 3) Scroll to offending line number... 

Now you're back in your editor, but once you've successfully
scrolled to the offending line, you quickly realize that --
RATS! -- in the process of eyeball parsing the exception
dump to determine the number of the offending line *AND*
scrolling to the offending line, you have forgotten the
whole reason why you were going here in the first place! (at
this point, rick's low tolerance for impracticality causes
him to become agitated, but knowing that emotion will not
solve his problem, rick begrudgingly goes back to the
console window and eyeball parses the exception dump (once
more!) for a clue to what the *HELL* has caused him to endure
all this trouble)... (a few seconds passes whilst rick speed
reads)... Okay, got it! Now,

(STEP 4) Return to the running editor; containing the
offending script; scrolled to the offending line -- with a
_bitter_ resolve to get this bug fixed!!!

Oh my!

There must be a better way.




More information about the Python-list mailing list