On Wed, 06 Jul 2005 15:18:31 GMT, Ron Adam <[EMAIL PROTECTED]> wrote:
> Dan Sommers wrote: >> On Wed, 06 Jul 2005 14:33:47 GMT, >> Ron Adam <[EMAIL PROTECTED]> wrote: >> >>> Since this is a Python 3k item... What would be the consequence of >>> making None the default value of an undefined name? And then assigning >>> a name to None as a way to delete it? >> [ ... ] >> >>> Any drawbacks? >> Lots more hard-to-find errors from code like this: >> filehandle = open( 'somefile' ) >> do_something_with_an_open_file( file_handle ) >> filehandle.close( ) >> Regards, >> Dan [ ... ] > If "file_handle" (vs "filehandle") is None. Then you will still get an > error as soon as you tried to use the invalid file handle. > AttributeError: 'NoneType' object has no attribute 'read' This is the one of which I was thinking. So you see this error at the end of a (long) traceback, and try to figure out where along the (long) line of function calls I typed the wrong name. Currently, the very end of the traceback points you right at the bad code and says "NameError: name 'filehandle' is not defined," which tells me (very nearly) exactly what I did wrong. > If the error was filehundle.close() you will get: s/u/a/ ;-) > I don't think any of those would be hard to find. I guess it depends on how long your traceback is and how big those functions are. Also, from the Zen: Explicit is better than implicit. although from previous threads, we know that every pythonista has his or her own definitions of "explicit" and "implicit." Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list