Results 1 to 6 of 6

Thread: Python error

  1. #1
    Join Date
    Jan 2012
    Beans
    161

    Python error

    def main():
    args = sys.argv[1:]
    if not args:
    print "usage: [--todir dir][--tozip zipfile] dir [dir ...]";
    sys.exit(1)


    elif args[0] == '--todir':
    todir = args[1]
    del args[0:2]
    if args:
    destination = args[0]
    copytodir(todir, destination)
    else:
    print 'error, closing.'
    sys.exit(1)

    In my IDE the bold line conforms to the indent, but how come here it does not? and when I try to run it I get an unexpected indent Traceback?

  2. #2
    Join Date
    Jan 2012
    Beans
    161

    Re: Python error

    <CODE>

    def main():
    args = sys.argv[1:]
    if not args:
    print "usage: [--todir dir][--tozip zipfile] dir [dir ...]";
    sys.exit(1)


    elif args[0] == '--todir':
    todir = args[1]
    del args[0:2]
    if args:
    destination = args[0]
    copytodir(todir, destination)
    else:
    print 'error, closing.'
    sys.exit(1)
    </CODE>

    should be more like it

  3. #3
    Join Date
    Jan 2012
    Beans
    161

    Re: Python error

    grrr now i cant even post code correctly.....

  4. #4
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Python error

    You need to use [CODE] [/CODE] tags to put a block of code in your post
    Cheesemill

  5. #5
    Join Date
    Jan 2012
    Beans
    161

    Re: Python error

    LOL I figured it out. For some reason geany and gedit were showing the code as properly edited. When I opened the code in kate and nano, it showed me where the indentation was off. I think it will be kate for me in the long haul.

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Python error

    This happens when you mix spaces and tabs - visually the same, logically not so much. Personally i set gedit to replace tabs with 2 spaces.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •