473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

syntax error in python

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
Feb 20 '08 #1
2 1568
On Feb 20, 2:03 pm, Lalit <lalitkris...@gmail.comwrote:
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
Feb 20 '08 #2
Lalit <la**********@gmail.comwrote:
>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, ti**@probo.com
Providenza & Boekelheide, Inc.
Feb 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
7
by: Petr Prikryl | last post by:
Hi, Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". Current situation: try... (Python 2.4 (#60, ...)) >>> i =...
2
by: George Sakkis | last post by:
I downloaded the latest Komodo (3.1) and configured it for python 2.4 so that it doesn't show decorators and genexps as syntax errors, but background syntax checking doesn't seem to work at all for...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
5
by: Sheldon | last post by:
Hi Everyone, I am new here but I am pretty good at python programming but I am not exert. I have been away from programming for about a year and now I am programming in python again in...
0
by: Travis Oliphant | last post by:
This post is to gather feedback from the wider community on PEP 357. It is nearing the acceptance stage and has previously been discussed on python-dev. This is a chance for the wider Python...
21
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload...
4
by: daniel | last post by:
I'm not quite new to this language, but such error has never happened so frequently before. I have no idea what to do about it, because there's actually no syntax error at all !! I'm using...
0
by: Timothy Grant | last post by:
On Fri, Aug 29, 2008 at 12:48 AM, Alexis Boutillier <alexis.boutillier@arteris.comwrote: http://docs.python.org/ref/import.html -- Stand Fast, tjg.
6
by: Daniel | last post by:
I hope this question is OK for this list. I've downloaded Rpyc and placed it in my site packages dir. On some machines it works fine, on others not so much. Here is one error I get when I try...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.