Jump to content



Recommended Posts


I am trying to learn python myself :) , and what I found is that you need to learn the basics of python syntax and functions, but if you really want to do stuff with python you need to get the APIs for the various modules you import into your programmes. You learn them as you go. Modules are pretty much a bunch of functions, so, if I had a module called 'helloworld' with code like this:

def print(check):
      if check == 1:
            return "Hello World!"

then I had another python file called 'hell~2.py' with this code:

import helloworld
print helloworld.print(1)

If I ran hell~2.py it would produce this:

>>Hello World!

Link to comment
Share on other sites

boardbreaker, you have to install python first, the latest version is 2.6.1, you can download it from here: http://www.python.org/download/

When you have installed python, you enter what I told you to enter into a text editor, and save it with a '.py' extension. With the example I gave you, you need to keep the names the same and for simplicity's sake, keep the files in the same directory, because they are referred to in the code. Python's 'default' IDE (that comes with the installation) is called IDLE, its quite good, it has syntax highlighting, and the interactive console provides a sandbox environment for you to test and run things, it also handles errors quite well, and unlike many languages, Python errors are *usually* quite easy to understand.

Link to comment
Share on other sites

the code I gave you was just a complicated way of making you get

>>Hello World!

in the console. It was to show you how modules and functions work.

Just to explain again: a function is a bit of code that takes some variables in, manipulates them and returns a variable or a number or something. Its a simple Input>>Process>>Output system, and it works quite well.

Link to comment
Share on other sites

Basically, by default, python scripts in windows run through the command prompt, which of course closes after it has executed everything you told it to. I recommend that you use IDLE instead (You will find it in your Program Files) Because it doesn't close when it finished executing code.

Link to comment
Share on other sites

Go to programs and open up IDLE. Then go up to file, and then new.

You can type, and save code there. Remember to add .py to your saved files, otherwise syntax coloring will turn off. IDLE is just where it is interpreted / a place to test code.

In IDLE you can type:

a = "Hello World!"
print a

It should print Hello World in the IDLE.

I like this Python Tutorial series

Python Tutorial

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...