0
# Check for log request
if len(sys.argv) >= 3:
    if sys.argv[3].lower() == 'log':
        logFiles = True

I haven't done Python for a while but I don't see anything wrong with the above code and it's saying that after the 'logFiles' before the = True is the problem.

Ideas?

6
  • 3
    .lower() missing parentheses Commented Dec 22, 2013 at 13:08
  • Still the same error. Commented Dec 22, 2013 at 13:10
  • 3
    try it by replacing tabs with space Commented Dec 22, 2013 at 13:14
  • Oh that works, that's odd.. Commented Dec 22, 2013 at 13:15
  • if you are using vim ( which you should :) ), you may add set expandtab in .vimrc file and it will always insert space instead of tabs. Commented Dec 22, 2013 at 13:29

1 Answer 1

1

Python 2 treats a tab the same way Notepad does - as enough spaces to reach the next 8-space indentation level. This means if you mix tabs and spaces, you might see code that looks perfectly well indented, but Python sees a garbled mess. (In Python 3, Python will give you a helpful TabError: inconsistent use of tabs and spaces in indentation if it sees that you're mixing tabs and spaces.) Your code has a tab on the second line and 4 spaces and a tab on the second. This looks like 1 indent, then 2, but Python doesn't see it that way.

Don't mix tabs and spaces. If you can, use the -tt interpreter option to detect this, and use an editor with an option to display whitespace characters.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.