On Mar 24, 2017 4:53 AM, "john polo" <jp...@mail.usf.edu> wrote: > > Greetings, > I am attempting to learn Python. I have no programming background. I'm on a computer with Windows 7. I checked the PATH in System Variables and Python and Python\Scripts are in the path. I have a book, Python for Biologists and it supplies example scripts, one is called comment.py. The output from comment.py is > > Comments are very useful! > > I use cd to get to the directory with the example scripts
We can assume you are at a Windows command prompt. It' a good idea too tell us that, so we don't have to assume! and open a command prompt with "python" and get the prompt. Assumptions / terminology again! Typing "python" normally invokes the python interpreter. Since you did not pass any arguments you get a window displaying the python interpreter prompt (>>>). I type > > "python comment.py" > > and get > > " File "<stdin>", line 1 > python comment.py > ^ > SyntaxError: invalid syntax It is great (as John said) that you provided the traceback. It would have been even greater if you had given us the rest e.g, Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\bgailer>cd /examples C:\examples>python Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> python comment.py File "<stdin>", line 1 python comment.py ^ SyntaxError: invalid syntax >>> Which brings up one other important matter: when writing us also tell us which python version you are using. In my example it is 3.3.5. > > Sorry, I realize this may not all line up like it does when I'm typing this in the email. The caret/error pointer is under the t in comment. I am not sure what is causing this error. > > If I type > > "import comment.py" > > the output is > > "Comments are very useful! > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ModuleNotFoundError: No module named 'comment.py'; 'comment' > " > > If I use IDLE shell: > > "python comment.py" > > "SyntaxError: invalid syntax" > > I know I can open the file in the editor and use F5, but shouldn't I be able to use a command from shell? How do I run comment.py from a command line without error? Or is that not possible? > > cheers, > John > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list