| | |
exec function in python 2.4
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2009
Posts: 6
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Dec 2006
Posts: 1,054
Reputation:
Solved Threads: 297
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.
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
•
•
Join Date: Aug 2009
Posts: 6
Reputation:
Solved Threads: 0
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.
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.
I found a copy of 'movable Python24' on one of my flash drives, and this works ...
In answer to your question, Python24 has the function exec().
python Syntax (Toggle Plain Text)
# excute a code string s = 'print "Hello!" ' exec(s) """my result --> Hello! """
May 'the Google' be with you!
![]() |
Similar Threads
- python can't pass arguements from a function to another function? (Python)
- Converting string to python code (Python)
- Matlab To Python (Python)
- A print function for compatibility with 3.0 ? (Python)
- pasting multiple lines into Python shell (Python)
- Like function in Python (Python)
- exec function on Windows XP (PHP)
- How do I cast a function type? (Python)
- Calling c function from python (Python)
Other Threads in the Python Forum
- Previous Thread: List of QWidgets with PyQt4
- Next Thread: Confusing strings
| Thread Tools | Search this Thread |
Tag cloud for Python
ansi assignment avogadro backend beginner binary bluetooth character cmd code customdialog cx-freeze data decimals dictionary drive dynamic error examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime program programming progressbar projects push py2exe pygame pyqt python random recursion recursive refresh schedule screensaverloopinactive script scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib






