/ Atom Script in Window10 / Can't see the result


#1

Hi, everyone. I just learn python and I have a question about the Script package.

This is the code

As we know to execute, Shift+Ctrl+b in Windows


#2

Hm…so If I execute the last line, I supposed to get the name 'Ben’
But nothing showed up…


#3

However, in python idle, it works…

like this mark >>>


#4

You’re not outputting anything. The last line should be print(employee.name).


#5

Thank you :slight_smile:


#6

Just a few notes that might help later on…

  1. The script package does not currently make provision to handle the input() command.
  2. The execution of your code with script is not interactive. You cannot interrogate the variables after the code was executed.

I have found these two points a problem for me, when working through tutorials. The options you have are:

  1. Install a shell or terminal that works inside Atom.
  2. Use the terminal program that comes with your OS.
  3. Use the Python shell IDLE.

The trouble with (1) and (2) is that you have to trigger Python as a command first. The default format is python myCodeFile.py. That is more-or less what script does, but input() is handled as you expect IDLE would.

The variation is python -i myCodeFile.py. This is interactive mode. The Python shell is kept active after execution of your code file. Variables can be interrogated. I find this VERY helpful. This is just like what IDLE gives you.

The package script-runner seem to have great promise aiming to be a mix between script and a terminal. The catch there is that you have to include in the first line a bang line which indicates how the script is to run. Unhappily I am currently having trouble with this package on Windows 7.

I hope you find these notes informative.
Have a PY good day.
dP


#7

TY so much Sir~!!