1
Tamara-Lovs-MacBook-Pro:~ Tamara$
Tamara-Lovs-MacBook-Pro:~ Tamara$ 1+1
-bash: 1+1: command not found

That is what comes up when I open the terminal.

Tamara Lov is the name my Mac is registered under. I played around with some preferences but don't know to use it.

slhck
  • 223,558
  • 70
  • 607
  • 592
tamara
  • 11
  • 1

1 Answers1

6

When you open your Terminal, you will land in a so-called shell. In this case, bash is the default shell which comes with OS X and it is started for you. Bash doesn't know the command 1+1.

To actually use python, you will have to start the python interpreter first. Do that with:

python

Now you can enter your live scripts.

enter image description here

If you write some scripts using a text editor, you can run them from bash by calling the following (for example, if your script is saved under Documents):

python /Users/Tamara/Documents/your-script.py
slhck
  • 223,558
  • 70
  • 607
  • 592
  • how do i open python? i thought the terminal automatically opens python. – tamara Nov 30 '11 at 23:25
  • No. The terminal automatically opens a shell for you, which you can use to open `python`. Python is just a program like many many others, it wouldn't make sense for a terminal just to open Python. You open Python by entering `python` in your shell. – slhck Nov 30 '11 at 23:27
  • that's amazing! it works! i didn't have this last time i opened the terminal- i dk why it automatically went into python... thank you so much, i really appreciate you helping me out. this is my first time using such a forum! – tamara Nov 30 '11 at 23:32
  • I'm glad to help. It could be that you've set up terminal to [automatically start python](http://i.stack.imgur.com/eJuCO.png) – but that's something you would have had to manually set. – slhck Nov 30 '11 at 23:34
  • hi- sorry i have another question. – tamara Dec 01 '11 at 01:52
  • im just at the phase of playing around with python. doing simple things like adding integars and strings. so for instance when i assign variable, like x=3*5. how can i change the variable after? also where do i write the code? – tamara Dec 01 '11 at 01:54
  • also how did you copy and paste a picture of the terminal above? – tamara Dec 01 '11 at 01:55
  • basically i think im asking is where do i "practice" the run before i put it into python in order to run module? – tamara Dec 01 '11 at 02:13
  • 1
    @Tamara Comment are *not* a chat. We do have an actual chat room though, the link is at the very top of the page. Regarding your questions, consider [reading up on the topic](http://www.diveintopython.net/) first. Your questions are both off topic on this site (we don't do programming questions outside a computer user context) and show a certain lack of understanding the basics – reading programming introductions will help you better than posting a string of trivial (for more advanced users) questions. – Daniel Beck Dec 01 '11 at 06:25
  • @Daniel- you don't have to be rude. I did not know these "rules" for asking questions and if everybody found my questions unfit then they don't have to answer it, it's ok. I can look elsewhere. Spend some more time speaking to human beings as opposed to interacting with computers. – tamara Dec 01 '11 at 18:53
  • 1
    @tamara *> how can i change the variable after? also where do i write the code?* – Please read a Python tutorial, as Daniel advised you. This is very basic programming. You normally write code from a text editor such as [TextWrangler](http://www.barebones.com/products/textwrangler/), save it to a file, and then execute this file with the `python` + filename command. – slhck Dec 01 '11 at 19:33
  • @tamara Inserting pictures in posts should be easy. There's a formatting help in the editor that explains you how to do it. Getting a screenshot on a Mac, [see here](http://superuser.com/questions/16613/how-to-take-screenshots-in-mac-os-x). Also, I don't think Daniel was being rude. He just pointed out that comments shouldn't be used like chat (because we have a chat). Nobody finds your question unfit here, but remember that on all Stack sites, off-topic questions can be closed, and bad questions can be downvoted, so please take a minute and read our [FAQ] to avoid any misunderstandings. – slhck Dec 01 '11 at 19:35
  • 1
    @tamara You're using comments like a real-time chat, sending four where one would suffice, perhaps not knowing that slhck is separately informed about every one of them. I just try to make you aware of it and offer alternatives, both to the comments and your problem more generally. I've used *Dive into Python* a few years back and found it helpful. If my comment *still* comes across as rude, bear in mind that this is written communication only; and English is a second language for many users on this site, including me, and outside a school or web context, many haven't had the chance to use it. – Daniel Beck Dec 02 '11 at 06:10
  • @tamara It is very frustrating to see one's posts deleted, or closed as unfit, and not being told what the problem is and it's a frequent complaint by many affected users. So whenever I see something on this site I consider off-topic, I let the users know the reasons. As a long-time active user, I am frequently right about this, judging similar to moderators. Would you instead prefer someone flagging your comments for moderator attention as *too chatty* (that's an actual reason!) or *off topic*, not letting your know about it and leaving you wondering why your stuff was deleted or closed? – Daniel Beck Dec 02 '11 at 06:18