Finding "hidden" syntax errors

Discussion in 'Python' started by Larry Bates, Jun 11, 2004.

  1. Larry Bates

    Larry Bates Guest

    It doesn't happen often, but once in a while I will
    introduce a syntax error into a Python program I'm
    working on (in IDLE) and doing File-Check responds
    with the expected "Failed to check, syntax error -
    invalid syntax". The problem is where the cursor
    stops is perfectly legal syntax. I then begin
    going through the laborious job of cutting out
    pieces of the code until I find what is wrong. Is
    there some easier way of doing this. I tried
    pychecker but got nowhere because it said it
    couldn't import (which I'm sure is because of the
    syntax error). Does anyone out there have a "better"
    way of tracking down these difficult to locate
    errors?

    Thanks in advance for any hints.

    Regards,
    Larry Bates
    Syscon, Inc.
     
    Larry Bates, Jun 11, 2004
    #1
    1. Advertising

  2. Larry Bates

    Miki Tebeka Guest

    Hello Larry,

    > I tried pychecker but got nowhere because it said it couldn't import
    > (which I'm sure is because of the syntax error). Does anyone out there
    > have a "better" way of tracking down these difficult to locate errors?

    I'm using pychecker. It says where the error is:
    --- syn.py ---
    def f(x):
    if x = 2: # Syntax error
    print "YO"
    else:
    print "Halt! Who goes there?"
    --- syn.py ---

    [10:45] $pychecker syn.py
    Processing syn...
    SyntaxError: invalid syntax (syn.py, line 2)
    if x = 2: # Syntax error
    ^

    Warnings...

    syn:1: NOT PROCESSED UNABLE TO IMPORT
    [10:45] $

    pychecker found out that the problem is in line 2.

    Maybe some concrete example?

    Bye.
    --
    -------------------------------------------------------------------------
    Miki Tebeka <>
    The only difference between children and adults is the price of the toys.
     
    Miki Tebeka, Jun 13, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    964
    Mark Goldin
    Jan 17, 2004
  2. Replies:
    1
    Views:
    407
  3. yawnmoth
    Replies:
    97
    Views:
    4,724
    Bent C Dalager
    Feb 27, 2009
  4. Rick
    Replies:
    3
    Views:
    8,195
    Alexey Smirnov
    Apr 13, 2010
  5. SolarCanine
    Replies:
    2
    Views:
    290
    SolarCanine
    Sep 20, 2005
Loading...

Share This Page