This neophyte requires assistance

A forum for general discussion of the Python programming language.

This neophyte requires assistance

Postby Ocular Blast » Sun Feb 09, 2014 6:31 am

Hello all.

I have a question regarding Python. I feel very silly asking this question as, given how quickly various Python sites and books quickly breeze over this section, it seems I should be able to perform this particular task quite easily. The task in question is calling a program via Python using the text, "python test.py".

For starters, I own a Mac. I have TextWrangler, and have saved programs in ".py" format. I have saved files on my desktop. I currently have a file titled, "test1.py" How would I call this file into Python? I really would like to know how to perform this task. My interactions with Python involve typing the code into the terminal (or the IDLE window which I just discovered how to call by luck), and seeing it appear (string) or executed (line of code). However, I know were I to properly perform the task I request assistance in, I would improve my programming abilities, and be able to write code in TextWrangler and have it appear executed in my Terminal or IDLE window. I know the task involves calling and creating directories but I'm not exactly sure what that means.

Help would be appreciated. Thank you for reading.
Ocular Blast
 
Posts: 1
Joined: Sun Feb 09, 2014 6:19 am

Re: This neophyte requires assistance

Postby stranac » Sun Feb 09, 2014 10:03 am

It's pretty straightforward.
Basically, you open up a terminal, use the command cd /path/to/myfile to go to where your file is, and then execute python myfile.py
An alternative is just executing python /path/to/myfile/myfile.py
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1209
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests