osx - Python: first test program -


i have copied , pasted below code textwrangler file called "ex1.py" have saved desktop (mac) , directory called mystuff etc compiler can't seem find file..i've tried maybe 50 times...

print "hello world!" print "hello again" print "i typing this." print "this fun." print 'yay! printing.' print "i'd rather 'not'." print 'i "said" not touch this.' 

i receive error 'no such file directory' when run "python ex1.py" (ex1.py name of test program). or when type "python" in terminal first current version info, type "python ex1.py" syntax error: invalid syntax. should create new directory 'mystuff' , navigate first when compiling terminal? (i thought didn't have compile python anyhow) please thanks.

here specific error

>>> python ex1.py file "<stdin>", line 1 python ex1.py          ^ syntaxerror: invalid syntax 

i have tried navigating file inputing "python, ^d, mkdir stuff, cd mystuff, ls, python ex1.py still no file found (i dragged file manually file btw)

yes idle works great thanks. should 1 'compiling' python there seeing mac terminal had trouble finding files (and still can't) though.

thanks help. python works in mysterious ways. lets share cheer , 1 of blokes rate me up. -2? cmon son -_-

got work in terminal navigating directory (python, ^d, cd mystuff, ls, cd newfolder, python ex1.py. worked charm. thanks

python not compiled, correct. when type in python terminal, takes python interpreter. try typing print 'hello world!' after have typed python in terminal.

have tried using idle? open interpreter (idle) launchpad, play around in there, click file>new file. when finish typing in program file, save it, press fn-f5. program run!

edit: python ex1.py not valid syntax, hence syntaxerror. when see >>> prompt, means using python interpreter, not terminal. if want run python file terminal type python ex1.py terminal , not python interpreter. , make sure in right directory in terminal can access python file.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -