seanm...@gmail.com wrote:
I am going to try posting here again with more detail to see if I can
finally get my first program to work.
I am working on a MacBook Pro with OS X 10.4.11. I opened a new window
in IDLE to create a file. The file had only one line of code and was
saved as module1.py. I saved it to Macintosh HD. The one line of code
in the file is copied below:
print 'Hello module world!'
I closed the file and tried to run it in IDLE and Terminal, but I have
had no success. I'll paste my commands and the error messages below
(for IDLE, then Terminal). Any help would be very much appreciated. I
feel like the marathon just started and I've fallen flat on my face.
Thanks.
IDLE 2.6.2
python module1.py
SyntaxError: invalid syntax
sean-m-computer:~ seanm$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
python module1.py
File "<stdin>", line 1
python module1.py
^
SyntaxError: invalid syntax
In both cases, you're already running python. Why would you expect to
have to run python inside python?
Once you're at a python prompt (in either of your cases), you use the
command "import" to load a module. And you do not put the ".py"
extension on the parameter. Specifically, it should look like this, and
very similar for IDLE.
M:\Programming\Python\sources\temp>c:\ProgFiles\Python26\python.exe
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import module1
Hello module world!
>>>
--
http://mail.python.org/mailman/listinfo/python-list