Python Forum
Power Shells vs Compile and Run programs?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Power Shells vs Compile and Run programs?
#1
Good morning,

I decided to take a crack at the edx machine learning course, and I had a question about how to approach writing the code.

They seem to run the programs from a powershell using the command line interface whereas everything I've done so far has been compile and run sort of code.

The code provided in the class is shown below, and I can call it from a powershell by typing in: python maze.py maze.txt

if len(sys.argv) != 2:
    sys.exit("Usage: python maze - DFS.py maze.txt")

m = Maze(sys.argv[1])
print("Maze:")
m.print()
print("Solving...")
m.solve()
print("States Explored:", m.num_explored)
print("Solution:")
m.print()
m.output_image("maze.png", show_explored=True)
Is the code above a better way to approach these types of problems, or should I aim to import the files and compile them together? I mean, I can compile and run it if I do something like this:

#I added this part to make it work
sys.argv = ["maze - DFS.py", "maze.txt"]
#I added this part to make it work

if len(sys.argv) != 2:
    sys.exit("Usage: python maze - DFS.py maze.txt")

m = Maze(sys.argv[1])
print("Maze:")
m.print()
print("Solving...")
m.solve()
print("States Explored:", m.num_explored)
print("Solution:")
m.print()
m.output_image("maze.png", show_explored=True)
Reply


Messages In This Thread
Power Shells vs Compile and Run programs? - by RockBlok - Jan-13-2024, 05:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using a script to open multiple shells? SuchUmami 9 637 Apr-01-2024, 10:04 AM
Last Post: Gribouillis
  Python Coding in Power BI Visual vjrans 0 316 Jan-31-2024, 07:54 AM
Last Post: vjrans
  How come my python shells are different? SuchUmami 2 637 Jul-10-2023, 08:00 PM
Last Post: snippsat
Question Python and Power BI Desktop dangermaus33 1 1,344 Jan-19-2023, 06:54 AM
Last Post: GetOnData
  Raising numbers to power ** GJG 3 2,478 Mar-23-2021, 03:43 PM
Last Post: deanhystad
  Detecting power plug Narayan 2 2,754 Aug-01-2020, 04:29 AM
Last Post: bowlofred
  NameError: name 'display' is not defined when running code on power bi beginner1 2 19,277 Jul-24-2019, 11:03 AM
Last Post: beginner1
  power spectrum from 2Dfft sdipti596 1 2,350 Mar-30-2019, 12:34 AM
Last Post: scidam
  python result problem of an iteration algorithm for power allocation Jessica 1 2,683 Sep-07-2018, 08:08 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020