Hey guys It's me again

by Dysolis

Back to Mechanic's Corner.

Unknown2010-08-03 21:32:19
QUOTE (Demetrios @ Aug 3 2010, 05:30 PM) <{POST_SNAPBACK}>
You compile C++ to run it, though. Python, you don't. You just install an interpreter and run it.



Indeed. You won't need py2exe unless you want to distribute something you wrote in python, but do not want to make the source code available.

Xavius2010-08-04 02:05:14
Python doesn't come native with all Windows installations, though, so you have to actually download Python.
Unknown2010-08-04 02:10:29
QUOTE (Xavius @ Aug 3 2010, 10:05 PM) <{POST_SNAPBACK}>
Python doesn't come native with all Windows installations, though, so you have to actually download Python.


... my bad, I keep forgetting it's not bundled as part of windows. I'm still not sure why they don't do that.
Dysolis2010-08-04 04:30:28
Hey Guys

I've started doing some programming and i'e got this small program here.
>>> x = int(raw_input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
... x = 0
... print 'Negative changed to zero'
... elif x == 0:
... print 'Zero'
... elif x == 1:
... print 'Single'
... else:
... print 'More'

...

It gives me the error invalid syntax and it highlights elif.

I got this from the website http://docs.python.org/tutorial/controlflow.html am I doing the syntax wrong?
Unknown2010-08-04 05:41:56
QUOTE (Dysolis @ Aug 4 2010, 07:30 AM) <{POST_SNAPBACK}>
Hey Guys

I've started doing some programming and i'e got this small program here.
>>> x = int(raw_input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
... x = 0
... print 'Negative changed to zero'
... elif x == 0:
... print 'Zero'
... elif x == 1:
... print 'Single'
... else:
... print 'More'

...

It gives me the error invalid syntax and it highlights elif.

I got this from the website http://docs.python.org/tutorial/controlflow.html am I doing the syntax wrong?

Check your indentation. Python is very strict about it.

Also, if you just copy-paste from that site to your own file, remove the ... at the begining of each line if you haven't.
Dysolis2010-08-04 06:04:25
I like to type it out so I might have some spaces that belong there so that might of been the problem. Thanks!
Dysolis2010-08-04 07:25:25
Ok this time i'm sure I have the indent right.

>>> def f(a, L=):
L.append(a)
return L
Print f(1)
SyntaxError: invalid syntax
>>>

the print is coming up with a syntax error
Unknown2010-08-04 08:26:22
QUOTE (Dysolis @ Aug 4 2010, 10:25 AM) <{POST_SNAPBACK}>
Ok this time i'm sure I have the indent right.

>>> def f(a, L=):
L.append(a)
return L
Print f(1)
SyntaxError: invalid syntax
>>>

the print is coming up with a syntax error

Are you running those line by line in Python, or do you create a script file?
If it's the first, I recommend creating a new test.py file and using any text editor copy this code in then run it with "python test.py".