anonymous
  • anonymous
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?
Computer Science
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

rsmith6559
  • rsmith6559
That program won't run if invoked like: ./sudoku.py There's no sh-bang. An interpreted program, like Python, has to have: #!/usr/bin/python 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: python ./sudoku.py You don't need execute permissions on sudoku.py for this invocation.
anonymous
  • anonymous
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) it works! 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.
1 Attachment
rsmith6559
  • rsmith6559
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__" ): grid_values(grid) If you want to test the individual functions, cd into the same directory as sudoku.py, In Terminal/X11 start Python: python Import sudoku.py: import sudoku Then you can run the individual functions: sudoku.grid_values(grid) with a value for grid.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Ah thanks so much! I am definitely a noobie with Python and all things Apple!
rsmith6559
  • rsmith6559
No problem. I've been programming in Python and a Systems/Network Admin since 1997, starting with IRIX and evolving into Macs.

Looking for something else?

Not the answer you are looking for? Search for more explanations.