Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Learning other languages is helpful when developing for iOS or anything in fact. This is what I'm told and I believe it.

However, I tried to learn python this morning for the very first time and I have spent all morning and not type one line of python code.

Apparently python is already installed on all Mac's these days but it may not be the latest version of python. So I download the latest version from python.org.

I also look for a decent IDE and I come across eclipse. Eclipse apparently needs some additional plug in software installed called pydev so I look for that and install it.

I then find out that I need to hook up the python interpreter in eclipse, which makes sense, so I hook it up and I get an error message saying the versions are incompatible.

I assumed the latest version of python, eclipse and pydev would be ok. What a waste of time.

So I figure, hey...let's just use terminal. There's probably loads of support for using python in terminal out there...

I was right. After a few searches I find loads of support, but almost all the tutorials I watch are not basic enough. I now I feel really really stupid!

For instance, one guy says create a python file on your desktop...HOW?
Another guy says type vi <filename>.py and then type the following code etc etc...but he didn't mention to cd first to the place you want the file to end up. Also, he said....then run the file...HOW?

Does anyone have a resource for THE MOST BASIC WAY to run Python in a terminal environment FOR A COMPLETE NOOB please?
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Here you go.

  1. Open Terminal
  2. Type nano test.py
  3. Add code and save it
  4. Close nano
  5. Type "python test.py" (without the quotes) and press return
  6. See the results of your program
  7. Job done

There is really no need for an IDE. If you want to use something a bit more powerful than nano then Vim or Emacs are the text editors to learn.

Edit: It sounds like you downloaded Python 3.x originally. This is an incompatible language to Python 2.x. If you are just starting the majority of Python documentation on the web assumes you are using Python 2.x which is what comes bundled with Mac OS X.
 

Fed

macrumors 6502
Jul 7, 2012
409
0
Liverpool.
Judging by your post, you should really learn more about computers before you start hacking Python code. You could do some serious damage. The fact you can't create a Python file (literally a computer file with .py at the end) says you really should stay away from the Python interpreter until you know some basics.

I don't mean to be a dismissive but seriously, you aren't going to program anything useful until you know what you're doing.
 

SteelWheel

macrumors member
Apr 16, 2008
88
0
If we're really concerned about OP hosing his machine in an effort to learn Python, then how about doing this?

Assuming his machine is running Lion or ML, he can always run Lion within Lion on a VM, and use the VM version as the environment in which to learn Python. If things get out of hand, just blow away the VM and start over.
 

thekev

macrumors 604
Aug 5, 2010
7,005
3,343

I went through that one. I wanted to know python as it's a common scripting language. Your link contains one of the greatest quotes ever, although it suggests that I will eventually migrate to Linux:D.



A programmer will eventually tell you to use Mac OSX or Linux. If the programmer likes fonts and typography, they'll tell you to get a Mac OSX computer. If they like control and have a huge beard, they'll tell you to install Linux. Again, use whatever computer you have right now that works. All you need is gedit, a Terminal, and python.
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
thanks for the info guys. learning python the hard way seems like a good link, so i'll give that a try.

i didn't realise the Mac OS Lion licence permitted Virtual Machines?
 

philosopherdog

macrumors 6502a
Dec 29, 2008
736
516
Python comes with its own IDE called idle. Just install it and look at a couple of YouTube videos. It's very easy to use and free. Avoid eclipse for now. It's a nightmare to set up and in any case a rather poor IDE for python.
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
I went through that one. I wanted to know python as it's a common scripting language. Your link contains one of the greatest quotes ever, although it suggests that I will eventually migrate to Linux:D.

This is a good one

"An 'octothorpe' is also called a 'pound', 'hash', 'mesh', or any number of names. Pick the one that makes you chill out."

Haha
 

thekev

macrumors 604
Aug 5, 2010
7,005
3,343
This is a good one

"An 'octothorpe' is also called a 'pound', 'hash', 'mesh', or any number of names. Pick the one that makes you chill out."

Haha

That author is just completely awesome.
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Having trouble understanding

Code:
def mysplit (string):
	quote = False
	retval = []
	current = ""
	for char == '"':
		quote = not quote
		elif char == ',' and not quote;
		retval.append(current)
		current = ""
	else:
		current += char
		retval.append(current)
		return retval

The above code is going to step through a string, character by character, and separate components that are separated by ','. If a ' " ' is found, something happens.

I understand that a boolean value changes from False to True if a ' " ' is found, but I can't see how it's returned to False in preparation for the next parsing event.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.