Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47643
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: "Don't rebind built-in names*" - it confuses readers |
| Date | 2013-06-11 09:09 +0200 |
| Organization | None |
| References | <kp5q5o$fj1$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3011.1370934571.3114.python-list@python.org> (permalink) |
Terry Jan Reedy wrote: > Many long-time posters have advised "Don't rebind built-in names*. I'm in that camp, but I think this old post by Guido van Rossum is worth reading to put the matter into perspective: """ > That was probably a checkin I made. I would have left it alone except the > code was > > file = open(...) > > As long as I was changing the variable name to not mask the builtin I > changed the call as well. Had it been > > f = open(...) > > I probably would have kept my hands off. Hm... I'm not particularly concerned over fixing all code that uses file as a local variable name, unless it actually is likely to need to reference the file class by name; builtins are in the last scope searched for the very reason that no programmer is expected to keep up with all additions to the built-in library, so locals hiding built-ins is okay. (Not that it isn't a good idea to avoid obvious clashes -- 'str' for string variables and 'type' for type variables being the most obvious stumbling blocks.) > In any case, I was under the impression that file() was the wave of the > future and open() a nod to the past. Now you know better... --Guido van Rossum (home page: http://www.python.org/~guido/) """ <http://mail.python.org/pipermail/python-dev/2004-July/045948.html>
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: "Don't rebind built-in names*" - it confuses readers Peter Otten <__peter__@web.de> - 2013-06-11 09:09 +0200
Re: "Don't rebind built-in names*" - it confuses readers rusi <rustompmody@gmail.com> - 2013-06-11 04:12 -0700
Re: "Don't rebind built-in names*" - it confuses readers Peter Otten <__peter__@web.de> - 2013-06-11 14:06 +0200
Re: "Don't rebind built-in names*" - it confuses readers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-11 13:34 +0000
Re: "Don't rebind built-in names*" - it confuses readers Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-11 08:43 -0700
Re: "Don't rebind built-in names*" - it confuses readers Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-11 17:29 +0100
csiph-web