Python Help

Started by
19 comments, last by Polantaris 17 years, 10 months ago
Boder, the whole thing that was confusing me was the fact that I didnt get ... I got
>>> #
>>>

not
>>> #
...

and that's why I was confused.

Okay Fruny, thanks for telling me that, I understand how it works now.
~Polantaris
Advertisement
Quote:Original post by Polantaris
Boder, the whole thing that was confusing me was the fact that I didnt get ... I got
>>> #
>>>

not
>>> #
...

and that's why I was confused.

Actually, you are seeing the correct behavior.

The ellipses (...) represent a continuation of a statement block. However, a comment is not a statement, much less a statement block. It is completely ignored by the compiler/interpreter, so it shouldn't modify the parser state and thus prompt you for a continuation.

In other words, the tutorial is, in this instance at least, wrong.
Actually, the Python interpreter on Linux did exactly as in the tutorial (that is, after typing a comment, I got an ellipse). Is it possible that the command line interpreter on Windows has a slightly different behaviour than that of Idle? I don't use Windows so I can't verify that.

To the original poster: sorry if my post mislead you. I tried your code in the command line interpreter in Linux and (wrongly) assumed that the behaviour would be consistent between implementations. I've never read the tutorial either (I'm not a pythonista).


Hope this helps.
Quote:Original post by Anonymous Poster
Actually, the Python interpreter on Linux did exactly as in the tutorial (that is, after typing a comment, I got an ellipse). Is it possible that the command line interpreter on Windows has a slightly different behaviour than that of Idle? I don't use Windows so I can't verify that.

The implementation of the Windows interpreter is actually irrelevant. The question here is What is semantically correct? Obviously, the interpreter should wholly ignore comments (they should have the same effect as simply hitting enter, which should present you with another prompt, not a continuation prompt).

In summary, the "interpreter on Linux" (what version?) is broken.
Quote:Original post by Oluseyi
In summary, the "interpreter on Linux" (what version?) is broken.


Actually, the command-line version of the interpreter on Windows behaves the same (prints the ...). So I guess it is a difference in the read-eval-print loops between the command-line and IDLE-embedded interpreters.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by Fruny
Quote:Original post by Oluseyi
In summary, the "interpreter on Linux" (what version?) is broken.

Actually, the command-line version of the interpreter on Windows behaves the same (prints the ...). So I guess it is a difference in the read-eval-print loops between the command-line and IDLE-embedded interpreters.

Then they're both broken. [smile]

Sorry, don't have an interpreter installed on this machine.
I dunno, I think I'm going to look for an online guide when I get home from school anyway, because that tutorial is very confusing, and isn't very understandable to me. Oh well, thanks for the help though.
~Polantaris
Quote:Original post by Polantaris
I dunno, I think I'm going to look for an online guide when I get home from school anyway, because that tutorial is very confusing, and isn't very understandable to me. Oh well, thanks for the help though.


There are a few tutorials linked from the Python website
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Alright now I have a new problem. I'm working on PyGame, with a tutorial from http://rene.f0o.com/mywiki/LectureOne It tells me to put the following down. It's obviously there to set the folder settings and such, in the Python command line (Dos version I guess), but I continually get syntax errors from PATH on the first line. I'm not too good at Python yet, being my first day with it, so I don't know what that command is, so I don't know how to fix it. (I noticed he still uses Python23 as the folder, but they are at Python24 as the folder name, so I changed it accordingly, was that a mistake?)

set PATH=%PATH%;c:\Python23
cd "\Program Files\Pygame-Docs\examples"
python chimp.py
~Polantaris
No, that goes on the *DOS* command line. It's for setting up the DOS prompt so that it knows where the Python interpreter executable (python.exe) is located, so that you can actually run scripts on the command line (with commands like 'python chimp.py') without the thing complaining.

This topic is closed to new replies.

Advertisement