syntax error in python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lalit

    syntax error in python

    Hi
    I am executing following commands.
    >>test = os.path.isfile( 'c:\\src\\kasjd fl.txt')
    >>print test
    True
    ------------working fine but for below statement it is giving syntax
    error.
    >>if (os.path.isfile ('c:\\src\\kasj dfl.txt'))
    SyntaxError: invalid syntax

    any idea what is incorrect in my syntax
  • Lalit

    #2
    Re: syntax error in python

    On Feb 20, 2:03 pm, Lalit <lalitkris...@g mail.comwrote:
    Hi
    I am executing following commands.>>test = os.path.isfile( 'c:\\src\\kasjd fl.txt')
    >print test
    >
    True
    ------------working fine but for below statement it is giving syntax
    error.
    >
    >if (os.path.isfile ('c:\\src\\kasj dfl.txt'))
    >
    SyntaxError: invalid syntax
    >
    any idea what is incorrect in my syntax
    oops got the mistake I was nt ending if with :
    sorry and thanks

    Comment

    • Tim Roberts

      #3
      Re: syntax error in python

      Lalit <lalitkrishna@g mail.comwrote:
      >Hi
      >I am executing following commands.
      >>>test = os.path.isfile( 'c:\\src\\kasjd fl.txt')
      >>>print test
      >True
      >------------working fine but for below statement it is giving syntax
      >error.
      >
      >>>if (os.path.isfile ('c:\\src\\kasj dfl.txt'))
      >SyntaxError: invalid syntax
      >
      >any idea what is incorrect in my syntax
      You know that this is not C, and that the parentheses are not needed in the
      "if" statement? In my opinion, they interfere with readability.
      --
      Tim Roberts, timr@probo.com
      Providenza & Boekelheide, Inc.

      Comment

      Working...