Proposal: add sys to __builtins__

Michael J. Fromberger Michael.J.Fromberger at Clothing.Dartmouth.EDU
Tue Sep 6 20:58:58 EDT 2005


In article <Xns96C86FC4A4820reederz at 63.223.7.253>,
 Rick Wotnaz <desparn at wtf.com> wrote:

> You're right that there is no necessity for such a change. I was 
> not actually talking about importing *any* module in every case, 
> but rather about importing, say, 'sys' when, for example, sys.argv 
> appeared in the code and no import had been specified.

I think I must have missed that post; I will go back and look at it.  
However, while I'm here, how would your proposal deal with code like 
this:

   import foobar

   # ... some while later ...
   def f( ... ):
      ...
      global foobar, sys
      sys = foobar
      ...

   # ... some while even later ...
   f( ... )
   sys.wallaby("Fear and loathing!")

In particular, we have no import of sys, but the name "sys" is 
meaningful as a local alias for a different module.  I'm not saying you 
couldn't deal with this, but it rules out some of the more obvious ways 
of detecting and automatically handling this kind of substitution.

Naturally, you might well ask, "why would you do such a fool thing?"  To 
this I can only respond:  "Never underestimate the ingenuity of fools."

-M

-- 
Michael J. Fromberger             | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA



More information about the Python-list mailing list