Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 2, 2012, 06:08 AM   #1
nashyo
macrumors 6502
 
Join Date: Oct 2010
Location: Bristol
Learning Python

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?
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Aug 2, 2012, 06:30 AM   #2
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: 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.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   1 Reply With Quote
Old Aug 2, 2012, 07:05 AM   #3
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by Cromulent View Post
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.
Nothing wrong with a GUI editor like TextWrangler or Fraise/Smultron ... either.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Aug 2, 2012, 07:13 AM   #4
Fed
macrumors 6502
 
Join Date: Jul 2012
Location: 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.
Fed is offline   2 Reply With Quote
Old Aug 2, 2012, 04:43 PM   #5
msdarkroom
macrumors member
 
Join Date: Jul 2012
Might want to consider this:

http://learnpythonthehardway.org/book/index.html
msdarkroom is offline   1 Reply With Quote
Old Aug 2, 2012, 05:39 PM   #6
SteelWheel
macrumors member
 
Join Date: Apr 2008
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.
SteelWheel is offline   0 Reply With Quote
Old Aug 3, 2012, 01:51 AM   #7
thekev
macrumors 603
 
thekev's Avatar
 
Join Date: Aug 2010
Quote:
Originally Posted by msdarkroom View Post
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.



Quote:
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.
__________________
world's largest manufacturer of tin foil hats, none of that aluminum foil crap.
thekev is offline   1 Reply With Quote
Old Aug 3, 2012, 04:17 AM   #8
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: 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?
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Aug 3, 2012, 06:11 AM   #9
Ap0ks
macrumors regular
 
Join Date: Aug 2008
Location: Cambridge, UK
Take a look at the Google Python class, it runs through quite a lot including getting your machine setup to write and execute simple Python scripts.

http://code.google.com/edu/languages...ass/index.html

Last edited by Ap0ks; Aug 3, 2012 at 06:12 AM. Reason: Forgot link ;)
Ap0ks is offline   0 Reply With Quote
Old Aug 3, 2012, 07:01 AM   #10
philosopherdog
macrumors 6502
 
Join Date: Dec 2008
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.
philosopherdog is offline   0 Reply With Quote
Old Aug 3, 2012, 08:51 AM   #11
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: Bristol
Quote:
Originally Posted by thekev View Post
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.
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
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   1 Reply With Quote
Old Aug 3, 2012, 09:01 AM   #12
Pivs
macrumors member
 
Join Date: Jul 2012
Location: Virginia
Codecademy just added some Python exercises. I haven't tried any of them out yet though, so I can't vouch for them.

http://www.codecademy.com/
Pivs is offline   0 Reply With Quote
Old Aug 3, 2012, 09:04 AM   #13
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by nashyo View Post
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
Hold me back!

Americans calling the hash symbol the pound symbol drives me mad. The pound symbol is "" mmmkay?
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Aug 3, 2012, 09:07 AM   #14
thekev
macrumors 603
 
thekev's Avatar
 
Join Date: Aug 2010
Quote:
Originally Posted by nashyo View Post
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.
__________________
world's largest manufacturer of tin foil hats, none of that aluminum foil crap.
thekev is offline   0 Reply With Quote
Old Aug 3, 2012, 09:42 AM   #15
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: 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.
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Aug 3, 2012, 10:33 AM   #16
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: Bristol
Got it...quite simple really. Used to obj C
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Aug 3, 2012, 11:12 AM   #17
Ap0ks
macrumors regular
 
Join Date: Aug 2008
Location: Cambridge, UK
Quote:
Originally Posted by Cromulent View Post
Hold me back!

Americans calling the hash symbol the pound symbol drives me mad. The pound symbol is "" mmmkay?
Technically that's the pound sterling symbol or pound sign, a pound is a unit of weight
Ap0ks is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Tags
python, terminal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Need HELP with a Python script BlueFielder Mac Programming 5 Sep 8, 2013 09:19 AM
Good Python 3.3 course vmachiel Mac Programming 2 Mar 11, 2013 03:42 AM
Python and NLTK GeoffWillis Mac Programming 2 Feb 15, 2013 11:59 PM
Python Environment Telp Mac Programming 2 Jan 12, 2013 11:37 AM
Python 3.2.3 dboxall123 Mac Programming 4 Sep 27, 2012 10:53 AM

Forum Jump

All times are GMT -5. The time now is 02:20 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC