Run Python in Atom, get results


#1

Hi,
I am a structural engineering student and I have a few assignments that are very repetitive and I will have to repeat the same procedure over and over again. As I wanted to learn code I decided to do code my spreadsheets instead of using Excel. I did a course in codeacademy on Java Script, and using Atom I was able to print my results using a package. Now I am going through Python and for my purposes I think it will be more useful, so I have done quite a bit on it as well, however I cant get it to print my result in Atom.

Can you help me?
I look at other discussion, and some people suggested to download platformio-ide-terminal, however I still cant get the code to run.

Best Regards,

Tsvetan Donov

PS My code is very simple, but I first wanted to see if i can see the results before I continue.


#2

Okay, your first problem is with MacOS. Specifically, with the Unix command line. Look at the path to your file: ~/Desktop/test code/Python. To get to the file in the terminal, you have to enter that string exactly, including the capital letters and the space. However, Unix commands use spaces to separate the different arguments, so your attempt to cd ~/test code is attempting to pass two arguments to cd, which only understands the first, and isn’t finding a test/ anywhere. You have to tell Unix to ignore the space, which you can do in one of two ways:

cd "~/Desktop/test code/Python"
cd ~/Desktop/test\ code/Python

In the first, the quotes encapsulate the string and tell the shell that the whole path is together. In the second, the \ tells the shell to treat the space as literally a space, and not as anything special. Both work for this purpose, but you will use both of those techniques in different situations.

Now, considering what you’ve told me about your tasks, I would actually recommend not using Atom for the repetitive part. Instead, use a REPL, like this one. When it comes to tweaking and running short pieces of code, nothing’s faster. When I’m trying to learn a new technique in Python or see if an idea will work, I use the REPL with generic variable names and sample input. Once I make it work as I want, I copy and paste the code into Atom.


#3

Awesome, thank you for the help.


#4

No problem. :slight_smile: