Reputation: 1
I wrote some python code 6 months ago on a Linux system. It worked perfectly, but now I installed IDLE 3.3 for Mac and I'm getting a lot of errors like "inconsistent use of tabs and spaces in indentation" Invalid syntax: on print command etc...
Does any one have an idea what can be wrong?
Upvotes: 0
Views: 104
Reputation: 11
I had this same evil problem last week. I blame IDLE... I think it displays tabs funny* so I thought my code was clean even when it was inconsistent.
*I have recreated my problems (inadvertently) and now I am sure IDLE was inserting spaces every time I hit the tab key. (FYI, spaces is the Python standard, but I haven't been following that.) On top of that, when I navigated the cursor through the tabbed indents with the arrow keys, IDLE was stepping through them like they were made of spaces (!). And lastly, it was putting in FOUR spaces and displaying them as EIGHT. This evil design decision cost me at least a half-hour. The bad indents looked identical to the good ones, and deleting the erroring indents and replacing them with new ones was also completely futile. Quite frustrating.
Upvotes: 1
Reputation: 539
"inconsistent use of tabs and spaces in indentation" means that your indentation uses a combination of tabs and spaces. Change all your indentation to tabs OR spaces to fix this.
In python 3+ print
is no longer a keyword. It's a function, so you have to call it as so:
print("Hello World!")
With the argument within parenthesis.
Upvotes: 1