Python: Late Binding
Late binding, aka late evaluation is, good; it saves the machine time. Do not evaluate unless you need it.
What then, if a system evaluate the file before no one is ever sure that the file would be used or not?
Here is something that you can have a very strong opinion on. Would you want the system evaluating just by open()ing the file?
Look at the following code in Python. This is just opening up a log file.
I am just setting the filename for logging. The file name could just be anything. <code>dummy.txt</code>, <code>> null</code> thing. Right?
Then it took me a while decoding the error message that the Python is giving me.
"Server error! The server encountered an internal error and was unable to complete your request.
Error message: End of script output before headers: index.py
If you think this is a server error, please contact the webmaster."
This is a part of the web system, a CGI script.
It turns out, that Python demands a file. The file must be accessible, and writable. The permission must be set writable, before running this code.
Evaluating the validity of the file access before even writing anything out -- that was rather unexpected.
What then, if a system evaluate the file before no one is ever sure that the file would be used or not?
Here is something that you can have a very strong opinion on. Would you want the system evaluating just by open()ing the file?
Look at the following code in Python. This is just opening up a log file.
import logging LOGFORMAT = '[%(asctime)s] %(filename)s (%(lineno)d): %(message)s' logging.basicConfig( filename='log/books.log', format=LOGFORMAT, datefmt='%Y-%m-%d %H:%M:%S', level=logging.DEBUG)
I am just setting the filename for logging. The file name could just be anything. <code>dummy.txt</code>, <code>> null</code> thing. Right?
Then it took me a while decoding the error message that the Python is giving me.
"Server error! The server encountered an internal error and was unable to complete your request.
Error message: End of script output before headers: index.py
If you think this is a server error, please contact the webmaster."
This is a part of the web system, a CGI script.
It turns out, that Python demands a file. The file must be accessible, and writable. The permission must be set writable, before running this code.
Evaluating the validity of the file access before even writing anything out -- that was rather unexpected.
Comments
Post a Comment