[Tutor] Some Python difficulties ..

Steven D'Aprano steve at pearwood.info
Sun Jul 10 05:16:03 EDT 2016

On Sun, Jul 10, 2016 at 02:23:23AM +0000, Chan Cheuk wrote:
> Dear all,
> I would like to know whether my designed Python program below for 
> Linux route command could not run and show the output onto the 
> textarea that I planned originally.

Did you try running it? What happened?

If you run your code from a shell, so you can watch any error messages 
that are generated, you will see this error whenever you click the Run 

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 1410, in 
    return self.func(*args)
  File "netcat.py", line 14, in startfping
    print "\tnetcat command: " + nccommand
NameError: global name 'nccommand' is not defined

> def startfping():
>     print "Start nc button clicked!"
>     fpingcommand = command_gen()
>     print "\tnetcat command: " + nccommand

Where is nccommand defined?

>     commandresult = runcommand()

How does runcommand() know what command to run?


More information about the Tutor mailing list