Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47643 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2013-06-11 09:09 +0200 |
| Last post | 2013-06-11 17:29 +0100 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2013-06-11 09:09 +0200 |
| Subject | Re: "Don't rebind built-in names*" - it confuses readers |
| Message-ID | <mailman.3011.1370934571.3114.python-list@python.org> |
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>
[toc] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-06-11 04:12 -0700 |
| Message-ID | <2eb38e14-55ea-4fe2-9108-9a13ef120a73@s2g2000pbz.googlegroups.com> |
| In reply to | #47643 |
On Jun 11, 12:09 pm, Peter Otten <__pete...@web.de> wrote: > 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: Not sure what you are saying Peter… If it is this (taken without context): > (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.) then I guess we are saying the same thing?? If however we consider the context of that message: First there was only open, then there came file, and file was considered better than open, now again file seems to have disappeared from python3… and this message is written in the context of making the 'kosherness' of one python generation become the *different* kosherness of the next… then what the message of the Guido-quote is, is not clear (at least to me).
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2013-06-11 14:06 +0200 |
| Message-ID | <mailman.3018.1370952362.3114.python-list@python.org> |
| In reply to | #47653 |
rusi wrote: > On Jun 11, 12:09 pm, Peter Otten <__pete...@web.de> wrote: >> 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: > > Not sure what you are saying Peter… If it is this (taken without > context): > >> (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.) > > then I guess we are saying the same thing?? > > If however we consider the context of that message: > First there was only open, then there came file, and file was > considered better than open, now again file seems to have disappeared > from python3… and this message is written in the context of making the > 'kosherness' of one python generation become the *different* > kosherness of the next… > > then what the message of the Guido-quote is, is not clear (at least to > me). As I understand it we should be a bit more relaxed about the matter of shading builtins with local variables than we usually are ;)
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-06-11 13:34 +0000 |
| Message-ID | <51b7277f$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #47653 |
On Tue, 11 Jun 2013 04:12:38 -0700, rusi wrote:
[...]
> then what the message of the Guido-quote is, is not clear (at least to
> me).
The relevant part is in the bit that you deleted. Let me quote it for you
again:
"locals hiding built-ins is okay"
-- Guido van Rossum, inventor and BDFL of Python
[deadpan]
Sorry for such a long quote, and I realise it's quite tricky to
interpret, so let me summarise for anyone still having difficulty:
GvR is saying that it's okay to use the names of built-in functions or
types as the names of local variables, even if that causes the built-in
to be inaccessible within that function.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Rick Johnson <rantingrickjohnson@gmail.com> |
|---|---|
| Date | 2013-06-11 08:43 -0700 |
| Message-ID | <1dc02b3c-8e2c-496f-9c6a-ce162c42b10b@googlegroups.com> |
| In reply to | #47660 |
On Tuesday, June 11, 2013 8:34:55 AM UTC-5, Steven D'Aprano wrote: > GvR is saying that it's okay to use the names of built-in functions or > types as the names of local variables, even if that causes the built-in > to be inaccessible within that function. Looks like we've finally found the traitor! Code smells propagating down from the apex of the pyramid... well thanks for the wonderful advice Guido, and with it you've cursed Python's stdlib to another decade of unprofessional code! PS: Excuse me whilst i brew myself a nice cup of HEMLOCK TEA!!! ಠ_ಠ
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-06-11 17:29 +0100 |
| Message-ID | <mailman.3027.1370968169.3114.python-list@python.org> |
| In reply to | #47668 |
On 11/06/2013 16:43, Rick Johnson wrote: > On Tuesday, June 11, 2013 8:34:55 AM UTC-5, Steven D'Aprano wrote: > >> GvR is saying that it's okay to use the names of built-in functions or >> types as the names of local variables, even if that causes the built-in >> to be inaccessible within that function. > > Looks like we've finally found the traitor! Code smells propagating down from the apex of the pyramid... well thanks for the wonderful advice Guido, and with it you've cursed Python's stdlib to another decade of unprofessional code! > > PS: Excuse me whilst i brew myself a nice cup of HEMLOCK TEA!!! ಠ_ಠ > At long last I've received some good news. But blast it, you've only said you'll brew it, not that you'll drink it. Still, I can but hope. -- "Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green." Snooker commentator 'Whispering' Ted Lowe. Mark Lawrence
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web