2014-06-20 15:21:53

Hi all,
I actually want to delve into Python because I like the idea of that Learn Python the Hard Way tutorial where you just type the exercises and gradually get an understanding of it as you type the code.
However, is there a good editor to use on the Mac? Python already comes with OS X apparently but do we really have to use the terminal? You can't really look at the input of code as easily in Terminal.
So, does anyone have suggestions? If I have to use the Terminal shell I will but I'd rather not.

Thumbs up

2014-06-20 22:34:08

Hello,
I don't use mac, but I'm not sure you are really understanding how python works.
In a text editor that creates txt files by default, (on windows this would be like notepad), you write the code. You save the file as a .py file (like filename.py). Then you open your console and mode to the directory where you saved the .py file. Then you type "python filename.py" and it runs. If you are able to read the output that is all you need. I don't ever use the interactive shell other than for a calculator.

Thumbs up

2014-06-21 21:19:24

Hi Frastlin,
Thanks, I kind of figured that's how it works, like BGT in that regard at least.
Are you going to release your adventure game Open Source? I'd be curious to look at it.
Than again, I wonder if I should because if I look at code and it looks too complex it may put me off.

Thumbs up

2014-06-21 22:51:19

Yes, my adventure game will be open source, but it will be for when you finish the tutorial. It is not put together well LOL, it makes sense to me though!
When you get to lesson 42 look at the source code at:
my over complex attempt at what they asked us to do
Let me know if you have any questions!
Check out USA games for a python blackjack example.
I'll probably write some novice games, like blackjack that are written correctly. I have one that is totally not.
blackjack
See if you can figure out what I could have done better!
Read the above when you are at around 25

Thumbs up

2014-08-06 07:25:14

Hi Orin,
One thing you need to keep in mind is that Python requires indentation. For instance, on a def, if, for, while, etc. block, you need to indent it. Keep this in mind when programming in Python.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2014-08-06 16:08:22

Yes, this makes code on the internet very difficult to read. I have a setting in both my text editor and my screen reader that will read \t (tab) as 4 spaces, so in the code I've written, I can read the "tab tab" for double indent.
So it would look something like:
def function1():
tab print "This is a function"
tab s = raw_input("Type something!")
tab if s == "no".lower():
tab tab print "Well **** you!"


arrowing through the above is exactly how it sounds when reading with my screen reader in my text editor. Otherwise it looks like:
def function2():
    """This is a test function"""
    print "Can you hear the indentation here?"

Thumbs up

2014-08-06 16:25:04

Speaking of my simplistic Blackjack game I probably should update that code and add some extras like some sounds as well as replace the global variables with classes etc. The current game is fine as is for a newbie programmer, but my aim at the time was simplicity rather than creating a complete game per se.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-08-06 23:38:00

@frastlin, Python wil lnot accept tabs. It only accept spaces; it can determine between a tab and a space. BTW, your using an out of date python version; the current version is version 3.4.1 I think.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up

2014-08-07 03:23:45

Ethin, a Python programmer can use tabs or spaces. It doesn't' really matter. I always use tabs in my Python code, and have never had the interpreter complain about my use of tabs instead of spaces.

As far as version goes that all depends on what a person is developing. While Python 3 is certainly preferable in many cases one must remember not all modules, APIs, are yet Python 3 compatible. As a result if a certain module or API only works with Python 2.7.x that's what the developer will use regardless if there is a newer and better version of Python available.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com