What am i doing wrong?

fattythefat

Chieftain
Joined
Feb 4, 2010
Messages
39
I read a guide about python and installed v. 3.1.2 (ithink) and then tried to do what the guide told me to do:
print "Hello, World!"

Then it says that this would come out:
Hello world

but i just get a synthax error and the last " begins glowing red...
what am i doing wrong?
 
That is the correct syntax. What is the exact message you received? Is it possible that you have two different quote keys like open quote and close quote, or single and double quotes? Both quotes in the line you gave should be the same character.

By the way, you do not need to install any python version to do modding within civ. Civ has its own python built-in. You can find instructions for this anywhere in the forum, and it varies on different international keyboards. Type the ~ character in your civ game, and you will get a python shell window. Type ~ again to get rid of it. I did this and typed your hello world command, and it worked correctly.
 
i wrote exactly what it says above... ill try again..
I get this message: Invalid synthax

Im using a danish keyboard and the ~ is a alt gr command... should i just hold alt gr and press the ¨/^/~ button?
 
Im using a danish keyboard and the ~ is a alt gr command... should i just hold alt gr and press the ¨/^/~ button?

I had the same problem. I'm using a Finnish keyboard and had to press SHIFT + ö to open the python console. If the ~ doesn't work, try other characters. It should be SHIFT + something.
 
Also important to note is that there are two different consoles. If the one you bring up doesn't explicitly say 'Python' in it, then you have the wrong one.
 
@fattythefat - If you cannot get any console to come up, where are you typing that print command?
 
Yes, but I thought from the other posts that fattythefat had perhaps used the other console in the game. Civ4 uses Python 2.4 (2.3 on the Mac) which you can definitely get from python.org. However, anything that works in these should work in Python 3.1.2. However, I wonder if Python 3 has changed the print command into a function. Try

Code:
print("Hello, world!")
 
About the console... Where is the shortkey defined, exactly? Because if its in the XML or Python, one could just change it from "~" to something else, like "#" or "@" (assuming that those characters are universally placed on all types of keyboards).
 
But what do you want to do?
Might be easier to circumnavigate the problem then trying to solve it.
I believe that he is trying to learn some basic Python in order to be able to get into modding. I'm sorta tutoring him in this thread, although I'm just a beginner myself. I actually downloaded Python and used IDLE for the first time in order to help him...

I can access the console on my Swedish keyboard by hitting shift + ö (or capital Ö), by the way. I can't understand why it would be so hard to find it on a Danish keyboard...
 
However, I wonder if Python 3 has changed the print command into a function. Try

Code:
print("Hello, world!")
That would be a good guess, actually. It would also explain the parenthesis used in the CivIV Python I've seen. (Mostly RFC mod.)
 
You definitely don't need the ()s in Civ4. I've used it without them, but I only use print in the Python console.
 
Oh yeah, I think you're right. Put in the chipotle code and get yourself a nice, fat burrito.
 
:lol: I took cheat mode for granted. :lol:

Also, you might need to press ctrl + z in order to activate all the features in cheat mode, or what ever.
 
Oh yeah, I think you're right. Put in the chipotle code and get yourself a nice, fat burrito.

:lol: I took cheat mode for granted. :lol:

Also, you might need to press ctrl + z in order to activate all the features in cheat mode, or what ever.

Thought so. I use cheat mode because of all the AI values are exposed, but I know the dev's wouldn't have let the console be exposed. Otherwise, I'd win every HOF game with "gc.getPlayer(0).setGold(99999999)"
 
CTRL + Z will let you see everything (map exposed, all players, see from their point of view in most screens), but it's not necessary to activate the console.
 
Top Bottom