On 2011-08-17, Steven D'Aprano <[email protected]> wrote: > On Wed, 17 Aug 2011 01:17 pm Seebs wrote: > [...] >> "Another" scope is normally a horizontal thing -- you're talking about >> a different scope such that you are *either* in this one *or* in that >> one.
>> Built-ins are not in a scope you are never not in. > That's technically incorrect. Built-ins are a scope you are never in, if > by "in" you mean "code is executed in this scope". No, by "in" I mean "lookups from your code will reach this scope if they don't find something sooner". >> Hmm. See, I've never reached that, in Python or any other language. I >> figure it creates a new potential for confusion, and that I would rather >> avoid any ambiguity. I don't *like* ambiguity in code. > Ah, well you see the thing is, this is Python. As soon as you call any > function you don't control, you no longer know what your environment is > with any certainty. For all you know, the harmless-looking function is > monkey-patching builtins like there's no tomorrow. Speaking broadly, > perhaps too broadly, we're incredibly proud of the ability to modify nearly > everything at runtime. Heh. > Fortunately, while we are proud of having that ability, actually *using* it > is considered a mortal sin. We're not Ruby developers -- if you actually > monkey-patch something, especially built-ins, you can expect to be taken > outside and slapped around with a fish if you get caught. Okay, so. Here's what I don't get. If it's such a bad thing, *why is it allowed*? Why are you proud of the ability to do something that you are never socially-allowed to do? I have mixed feelings about Ruby's general tolerance for monkey-patching, although I've seen it do some pretty awesome things, so I am somewhat inclined to accept that it may be worth it. But it's clearly a feature which is used intentionally. It sounds to me like Python is very proud of having a feature which no one would ever use. ... Why? > Sure. But they can't have that certainty regardless of whether you shadow > something, because how do they know whether you've shadowed it or not? Well, they could trust me. :) > In theory, anything could be anything at any time, and you have no > protection. In practice, I worry more about being eaten by > genetically-engineered flying piranhas than about rogue monkey-patching > code. I do too, if I know that people don't shadow built-ins. If I know that people are shadowing built-ins, then some of the time, when I'm editing other peoples' code, they HAVE effectively monkey-patched it. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / [email protected] http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list
