Archived

This topic is now archived and is closed to further replies.

Womble

Python begginer questions

Recommended Posts

Womble    122
I have just started to learn python and it is going well at the moment. I gave up C++ when it started to get complicated and i lost understanding. I moved onto python becuase i heard that it was easy so I would learn how to programme in general before i moved onto a more complicated language. Anyway, the questions 1)I can make a file in 2 ways, i can use idle and start a new window where i can type the code and run the program within idle or use notepad and save it as .py. When i run this program in .py form the dos screen pops up and the propgram executes very rapidly and exits if no input is required. Is there a way to have ''Press anykey to continue'' like in c++ at the end of a programme? 2)I learned python with the aim to start game programming. People have suggested to me to start with a text based game. What do you mean by that and could you post an example in any langauge becuase i want to see the idea of the game and not the code. 3)I have learnt the bits that i already knew in C++ in python now so i know a little of 2 languages. Should i carry on with python or start Java or even try C++ again. I have IDLE for python, the IDE that comes with java and VC++ 6 so compilers arent necessary. Thanks for your help

Share this post


Link to post
Share on other sites
Pinguino    122
Alright, when your in IDLE open a new window, in that blank window you can write the source code for your programs. When you want run your program, you have to save it and then you can run the module, it should run in IDLE not in DOS since its a scripting language it shouldnt be compiled into an executable.

For game programming with Python go to pygame.com, it has whole libraries of modules that you can use and tutorials so you can start making your own stuff. Alot of its pretty advanced to me.

In my opinion you should stick with C++ since it''s portable, more powerful and it has way more resources than Python. But if you want to theres nothing wrong with sticking with Python then moving on to Java using Jython, then maybe C++. But going straight to C++ is kinda faster, Python does use OOP so you can learn with Python. Since Python can be integrated with C++ its not such a bad idea to learn both.

I hope that was helpful.

Oh and how far did you get with C++, and how far are you with Python?

Share this post


Link to post
Share on other sites
Pinguino    122
For a really good C++ resource for learning the basics go here: http://discostu.virtualave.net/

That''s the book Teach Yourself C++ in 21 Days second edition, sure the book is a little bit out-dated but its still a better resource than an online tutorial. Its the whole book without the Index.

Share this post


Link to post
Share on other sites
Womble    122
In C++ I got to refernces and function references I think. I came to a point where i was no longer reading it once and understanding it with exercises and that i was reading the sections multiple times and typing in examples with no understanding. I was using Teach Yourself C++ In 21 Days and from day 9-10-11 was when I got lost. I stopped at this point for a month before starting python. Any better resources/books etc?

In Python I know loops, string things such as max(), min(), split(), capitalize() etc, accesing documents, editing + reading documents. Just started functions but this is simple at the moment bexuase it is very similar to C++. Is there a way to view documents in a folder?

I want to learn the concept of programming and thinking how to break a problem down into smaller tasks using a simple language rather than tacklineverything with C++.



[edited by - Womble on September 3, 2003 10:47:57 AM]

Share this post


Link to post
Share on other sites
Fruny    1658
1) Open an actual command line window and run your program from there instead of double-clicking on the icon. That way, all the output of the program goes to the already open window, which stays open until you close it yourself.

Alternatively...

import msvcrt
...
# clear the keyboard input buffer
while msvcrt.kbhit():
msvcrt.getch()
print "Press a key to continue."
# wait for a key
msvcrt.getch()


Note - if you add the extensions .py;.pyc;.pyw;.pyo to the PATHEXT environment variable (My Computer->Properties->Advanced->Environment Variables->System Variables), it will enable you to run 'foo.py' by just typing 'foo' on the command line.

2) A text game is (obviously) a game where all the I/O is text. That means the player must type his commands and the game prints out the results. e.g. INFOCOM-style adventure games, MUDs, guess-my-number ...

3) Carry on with python, learn it well, then come back to C++ and Java - as Pinguino mentioned, they will let you write extensions to Python (whatever bit of code runs too slowly in python can be rewritten in C, C++, Java, Fortran ... and used as if it were still native Python code - just much faster). However, I would advise you to stay clear off the C++ 'for beginner' books usually recommended around here, as too many are of low quality and/or hopelessly outdated.

One of the best introductory C++ books is 'Accelerated C++' by A.Koenig and B.Moo. It's a bit steep, but *correct*. For a gentler, more general tour of C++, read 'Essential C++' by A.Lippman (author, among other books, of the 'C++ Primer').

You can also consult the Association of C/C++ Users book recommendations by following the appropriate link in my signature.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on September 3, 2003 10:59:33 AM]

Share this post


Link to post
Share on other sites
Pinguino    122
Well, there really isnt anything I can do to help you since you are more advanced than I am in C++ and Python. I just started learning c++ yesterday (literally) I just started day 4 todayplanning on going all the way to 6 for today. I know some pretty basic C but thats about it, I just used Python to learn a few programming keywords and concepts so I can move on to C++.
What are you using to learn Python?

Share this post


Link to post
Share on other sites
tortoise    122
If you''re just starting out I think it''s a good idea to find a language you''re comfortable with and learn how to program with it, even if it''s not C++ or whatever is most popular. Once you get one language under your belt, the next one''s a lot easier.

quote:
Original post by Womble
2)I learned python with the aim to start game programming. People have suggested to me to start with a text based game. What do you mean by that and could you post an example in any langauge becuase i want to see the idea of the game and not the code.



http://www.douglasadams.com/creations/infocomjava.html

there, go play Hitch-Hiker''s Guide To the Galaxy in your webbrowser, a classic example of a text adventure game. If you''re not sure what to do, type "stand" then "turn on light", that should get you started.

There used to be a Zork Java applet (which is a true classic of the genre), but I can''t find it anymore.

But keep in mind a text adventure game is actually pretty challenging, it''s difficult to interpret what the user typed in and figure out what they want. You might wanna do say a text version of Tetris or something.

Share this post


Link to post
Share on other sites