Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

mileaga Group Title

Please forgive me if this is too basic...I'm running Python in Linux. It's already installed and I open it through a terminal and not a separate IDLE. I've written my first program, but I don't know how to test it. I don't know how to get Python to look for it in the right place. Does that make sense?

  • one year ago
  • one year ago

  • This Question is Open
  1. s3a Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Does cd /the/dir/it/is/in and then python3 filename.py work?

    • one year ago
  2. Alchemista Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Yeah, as s3a said you can run it with "python filename.py"

    • one year ago
  3. s3a Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Also, on Debian, I'm pretty sure "python" uses whatever is default but if you use the "python2" or "python3" command, you get to explicitly choose which version you use.

    • one year ago
  4. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    If I assume you've got a textfile with your python program, you can run it from the python console by calling `execfile( "program.py" )` (or e.g. `execfile( "../test/program.py" )` ). You can also simply call `python program.py` from your terminal. Another way, which is the way I usuallt prefer, is by putting a line in front of your script that tells the terminal how to execute it. You can then simply run your program from the terminal (e.g. ./program.py) if you make it executable. The line will be something like `#!/usr/bin/python` (and it should be the first line in your file). This will also work for perl/ruby/bash scripts.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.