Michael J. Fromberger wrote:

 > While I'm mildly uncomfortable with the precedent that would be set 
by including the contents of "sys" as built-ins, I must confess my 
objections are primarily aesthetic:  I don't want to see the built-in 
namespace any more cluttered than is necessary -- or at least, any more 
than it already is.


I agree with this sentiment, and I'll also additionally say that 'import 
sys' doesn't seem to be needed when writing sufficiently high-level 
code.  My python mud client (forever in development, but the 
structure-code is mostly done) uses TKinter, Twisted, and glue code for 
just about everything.

In currently 1,080 lines of Python code (reported by wc -l, so it 
includes a few blank lines) in 9 files, I needed "import sys" once. [1]

After I import sys, I use it exactly once -- I check the platform so I 
can use the higher resolution time.clock on win32 [time.time on win32 
(win2k) seems to have a resolution of 10ms, while on a 'nix I tested 
with time.time has at least ms resolution].  I'll probably use sys again 
somewhere to build an automagic version/platform string, but uses for it 
seem to be very limited.

I also have 0 imports of 'os', and the only immediately useful case that 
comes to mind is implementation of a #dir scripting command -- providing 
a minimal shell functionality, and this is certainly not a core 
component of the program.

In my opinion, using 'sys' and 'os' are extreme examples of "low-level" 
Python programming.  This sort of thing is probably very useful for 
writing actual scripts that replace the sort of work done by shell 
scripts, but as programs get more complicated I think they'd be used 
(proportionally) less and less.

I'm -0.9 on sys (really don't like the idea but it wouldn't be awful to 
see it included in __builtins__, provided it's namespaced appropriately) 
and -1 on os.

[1] Actually, it's in there three times, but they're all in the same 
file -- I'd just left a legacy 'import sys' in a couple local scopes and 
forgot to remove them.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to