views:

669

answers:

1

[resolved]

I tweaked the preferences in komodo edit and ended up with:

don't auto indent

don't allow file contents to override tab settings

prefer tab characters over spaces

4 spaces per indent

4 width of each tab char

I also set komodo to show whitespace and tabs, which eneded up revealing the screwed up sections.

yeah - it's a little picky. :)

[/resolved]

I have installed python 3.0 on ubuntu 8.10 along with komodo-edit ide.

I'm just getting into python, and I'm reading through visual quickstart guide python 2nd ed. (the example below is from that book). I'm getting some really frustrating errors and would really appreciate your thoughts.

I've re-typed and checked tabs many times over.

I'm starting to think that something in the install or setup has gone wrong.

I typed the following into komodo-edit:

#!/usr/bin/python3.0
for row in range(1, 10):
    for col in range(1, 10):
        p = row * col
        if p < 10:
            print(' ', end = '')
        print(row * col, ' ', end = '')
    print()

I can't test this is IDLE with python 3 - can't seem to get that version of IDLE installed. for now, I'm trying to run from the shell.

first, just using "python" to call the program...

PYTHON [1] $  python ktest.py 
      File "ktest.py", line 6
        print(' ', end = '')
                       ^
    SyntaxError: invalid syntax

now trying different ways of calling the python compiler...

PYTHON [1] $  python ktest.py 
          File "ktest.py", line 6
            print(' ', end = '')
                           ^
        SyntaxError: invalid syntax


PYTHON [1] $  python3 ktest.py 
      File "ktest.py", line 4
        p = row * col
                    ^
    TabError: inconsistent use of tabs and spaces in indentation


PYTHON [1] $  python3.0 ktest.py 
      File "ktest.py", line 4
        p = row * col
                    ^
    TabError: inconsistent use of tabs and spaces in indentation
+1  A: 

The example used python 2.x , since python apparently referred to python2.x (for some x), not python3.0 (which is good, since most programs are for 2.x).

The second two examples used python 3.0 . You mixed tabs and spaces in your source, and should get rid of the tab characters (don't retype-- use regular-expression replacement). Python 3.0 is more sensitive about this than 2.x-- you can get the same behavior using python -tt for 2.x .

Devin Jeanpierre