[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

syntax error in python

Lalit

2/20/2008 10:03:00 PM

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

>>> if (os.path.isfile('c:\\src\\kasjdfl.txt'))
SyntaxError: invalid syntax

any idea what is incorrect in my syntax
2 Answers

Lalit

2/20/2008 10:06:00 PM

0

On Feb 20, 2:03 pm, Lalit <lalitkris...@gmail.com> wrote:
> Hi
> I am executing following commands.>>> test = os.path.isfile('c:\\src\\kasjdfl.txt')
> >>> print test
>
> True
> ------------working fine but for below statement it is giving syntax
> error.
>
> >>> if (os.path.isfile('c:\\src\\kasjdfl.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

Tim Roberts

2/21/2008 6:59:00 AM

0

Lalit <lalitkrishna@gmail.com> wrote:

>Hi
>I am executing following commands.
>>>> test = os.path.isfile('c:\\src\\kasjdfl.txt')
>>>> print test
>True
>------------working fine but for below statement it is giving syntax
>error.
>
>>>> if (os.path.isfile('c:\\src\\kasjdfl.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.