exec function in python 2.4

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 6
Reputation: rajivgupta1107 is an unknown quantity at this point 
Solved Threads: 0
rajivgupta1107 rajivgupta1107 is offline Offline
Newbie Poster

exec function in python 2.4

 
0
  #1
Sep 14th, 2009
Hi,

I am having python 2.4 on linux machine. I am using exec funcation as:


objconfigfile=open(path, 'r')
for line in objconfigfile.readlines()
if line == None:
continue
exec(line)


It is throwing exception as:
invalid syntax for "exec(line)"

Please let me know the issue, do we have exec function in python 2.4?

Kindly update
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,054
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 297
woooee woooee is offline Offline
Veteran Poster

Re: exec function in python 2.4

 
1
  #2
Sep 14th, 2009
There is an error on this line, no colon
for line in objconfigfile.readlines()

I would suggest that you print every line because
if line == None:
will probably never be true, but you will have to print it and see. Also, exec(line) expects "line" to be a valid python statement.
Last edited by woooee; Sep 14th, 2009 at 4:35 pm.
Linux counter #99383
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 6
Reputation: rajivgupta1107 is an unknown quantity at this point 
Solved Threads: 0
rajivgupta1107 rajivgupta1107 is offline Offline
Newbie Poster

Re: exec function in python 2.4

 
0
  #3
Sep 14th, 2009
Hi,

sorry there is : specified for the loop.
Its basically reading from configuration file having following text:

Previous_Days_Raw_Zip_Files_Delete_Applog =.0000002
Previous_Days_Raw_Zip_Files_Delete_Eventlog =.00000002
Directory_Path_Eventlog=['1003\\10.1.44.200\\Event_Log\\','1006\\10.4.192.21\\Event_Log\\']
Directory_Path_Applog =['1003\\10.1.44.200\\App_Log\\','1006\\10.4.192.21\\App_Log\\']
Common_Path_Indial="//MIS/E://One97DWH//MIS_Phase2//Indial//Release//ETTL//Input_Files//"
Zipped_File_Format = "%Y-%m-%d"
Zip_Files_Deletion_Flag_Applog = "Y"
Zip_Files_Deletion_Flag_Eventlog = "N"
Log_File_Path = "C:\\Logs\\"
Log_File_Path1 = "//MIS/E://One97DWH//MIS_Phase2//Indial//Release//Python//Logs"

So there is no blank line in this text.
Please let me know the possible cause of issue.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,109
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 943
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: exec function in python 2.4

 
0
  #4
Sep 14th, 2009
I found a copy of 'movable Python24' on one of my flash drives, and this works ...
  1. # excute a code string
  2. s = 'print "Hello!" '
  3. exec(s)
  4.  
  5. """my result -->
  6. Hello!
  7. """
In answer to your question, Python24 has the function exec().
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 6
Reputation: rajivgupta1107 is an unknown quantity at this point 
Solved Threads: 0
rajivgupta1107 rajivgupta1107 is offline Offline
Newbie Poster

Re: exec function in python 2.4

 
0
  #5
Sep 14th, 2009
What can be issue with my program and file ?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,109
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 943
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: exec function in python 2.4

 
0
  #6
Sep 14th, 2009
Originally Posted by rajivgupta1107 View Post
What can be issue with my program and file ?
Like our friend woooee stated, the lines in your file are not valid Python executable statements!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC