Jump to content
  • Advertisement
Sign in to follow this  
Polantaris

Python Help

This topic is 4516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've decided to start trying to learn Python, and I'm reading the Tutorial that coems with the program. It's showing me how to do the "Interperter" or whatever it's called and it shows this: >>> 2+2 4 >>> # This is a comment ... 2+2 4 How do I get the ... after the # This is a comment? I would think its some kind of extra code or something you have to type, but I can't find where the Tutorial explains how to get this. Can anyone help me?

Share this post


Link to post
Share on other sites
Advertisement
You can think of an interpreter as a way to execute python code in real time. If you're familiar with compilers, it's essentially the same thing only instead of generating an executable file, it runs your code then and there.

Anyway, what exactly are you trying to get here? You want to type a comment into the interpreter and have the next line print an elipse (...)? Out of context I'm not sure what the example in the book is supposed to mean, but perhaps if you clarify a bit we can help you out.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You type it exactly as in the tutorial. That is, type the comment and hit enter, you'll see the ellipse. :-)


Hope this helps.

Share this post


Link to post
Share on other sites
Okay with the main problem I'm getting here, is that

This is what it says exactly on the Tutorial
In the following examples, input and output are distinguished by the presence or absence of prompts (">>> " and "... "): to repeat the example, you must type everything after the prompt, when the prompt appears; lines that do not begin with a prompt are output from the interpreter. Note that a secondary prompt on a line by itself in an example means you must type a blank line; this is used to end a multi-line command.

>>> is supposed to be like the beginning of a mutli-lined code or a single line code, and ... is supposed to be continuing a multi-lined code, or that's what I think. Either way, it never really explains how to get to ..., which is why I'm confused. I'm just trying to do the examples in the Tutorial so that I can learn the basics.

stuff with nothing before is is output, and the rest is input.

Also, is there a Non-Interperter with Python, or is all real-time execution? The only load up stuff that gets added to my start bar is interperters. Therefore, I just assume that's how it goes.

Share this post


Link to post
Share on other sites
Assuming you are using IDLE, I thought it did it automatically. I haven't used it in a while, but I thought it wouldn't evaluate until there is a complete statement.

Quote:
Original post by Polantaris
Also, is there a Non-Interperter with Python, or is all real-time execution? The only load up stuff that gets added to my start bar is interperters. Therefore, I just assume that's how it goes.


There are multiple IDEs for python. When you download the interpretor it come with IDLE (which is what I assume you are already using). You should be able to "creat new file" or something that will bring up a new window.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
You type it exactly as in the tutorial. That is, type the comment and hit enter, you'll see the ellipse. :-)


Hope this helps.


I guess not, because when I hit Enter, it just gives me another >>>, unless its supposed to? The Tutorial is alittle confusing if you ask me.

Share this post


Link to post
Share on other sites
Quote:
Original post by Polantaris
I guess not, because when I hit Enter, it just gives me another >>>, unless its supposed to? The Tutorial is alittle confusing if you ask me.


Yeah, it's normal. Don't worry about it.

Share this post


Link to post
Share on other sites
I'm on Windows and it works for me. I see

>>>

And I type just the hash(pound) sign and enter. It gives me

>>> #
...

You might have to say what version of python you're using and what OS.

You can do big projects and run them from the command line like so:

python myprog.py

where myprog.py is a python script you wrote.

Share this post


Link to post
Share on other sites
Quote:
Original post by Polantaris
Oh alright. Is there a normal non-real-time compiler for Python? If not, how do I do big projects with it then?


If you're using IDLE, hit CTRL+N (or File->New Window). It'll give you a text editor window in which you can write your code. Save it (with a .py extension), then use the Shell and Run menus.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!