Can anyone tell me why i can’t run python using ./ but able to use python
-rwxr-xr-x@ 1 xxxx staff 258 14 Nov 14:08 ltry.py
-rwxr-xr-x@ 1 xxxx staff 1037 14 Nov 11:20 pdTry.py
xxxx-MacBook-Pro:python xxxx$ ./ltry.py
File "./ltry.py", line 10
print "Hello you"
^
SyntaxError: invalid syntax
xxxx-MacBook-Pro:python xxxx$ python ltry.py
Hello you
['ltry.py']
Also, i installed python IDLE, but i wan’t able to try print, why?
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> print 'eeere'
SyntaxError: invalid syntax
>>> print "helooe"
SyntaxError: invalid syntax
For the second question, you are using Python 3.X there, where the syntax for printing was changed from the 2.X style you are using (
print 'string'isprint('string')in 3.X). My bet is that for the first question, you have 2 installations of Python on your machine, one 3.X, which is being called as the default program for .py files, and one 2.X, which is being called when you explicitly call python.