Anybody have python program that run's under IDLE but not directly from MacBook Pro terminal?
I have been OK with MIT example programs either way. When I tried Peter Norvig's http://norvig.com/sudoku.html Sudoku Program it ran ONLY under IDLE. Anybody have an idea why?
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
That program won't run if invoked like: ./sudoku.py
There's no sh-bang. An interpreted program, like Python, has to have:
as the first line. The "#!" is referred to as a pound bang or sh-bang. That tells Unix that the following program (python) is to be started, and this file (sudoku.py) should be given to python for processing. The path to the interpreter has to be an absolute path. The line that I wrote will probably work fine for your Mac. The Python program has to have execute permissions.
You should be able to run sudoku.py by invoking it like:
You don't need execute permissions on sudoku.py for this invocation.
Well I tried that and no luck. I am attaching sudoku.py I go into terminal and type python to bring up the python shell. I am using MacVim as my editor but am new to it. I copy the file and paste it into the terminal window. When I invoke parse_grid(grid) I get the following error messages:
Traceback (most recent call last):
File "", line 1, in
File "", line 8, in parse_grid
File "", line 5, in assign
File "", line 5, in
NameError: global name 'eliminate' is not defined
If I open IDLE and then File Open sudoku.py
Run - Run Module
then type parse_grid(grid)
I am trying to get to display(solve(grid)) which works under IDLE.
grid_values(grid) works directly from the terminal, but very little else.
I keep wondering if IDLE imports a module automatically that somehow I have missed when doing this directly from terminal.
Appreciate the help! Shalom.
TBH, I've never heard of MacVim. I use vi (vim VI iMproved) in Terminal/X11. Looking over your program, there's no __main__. No place for execution to start. If you want this to run as a program, append the following:
if( __name__ == "__main__" ):
If you want to test the individual functions, cd into the same directory as sudoku.py, In Terminal/X11 start Python:
Then you can run the individual functions:
with a value for grid.