Best practices with import?
Tom Bryan
tbryan at python.net
Sat Jul 28 13:36:43 EDT 2001
Alex wrote:
> Goodness, without import, python's close to useless.
Well, of course. But where to import? What's the most common idiom?
import sys, os, string
or
import sys
import os
import string
or
import sys as _sys
and where Python programmers expect to see the imports?
> I'm not sure what advantage there might be to deleting module references
> in a function's scope just prior to leaving it. I would have thought
> the reference was usually dropped at that point, anyway.
After digging at Google Groups, I think that it might have been a comment
about importing and then deleting at the module level. At least, I see
that the timbot is still explaining why threading.py does this.
import sys
import time
import thread
import traceback
import StringIO
# Rename some stuff so "from threading import *" is safe
_sys = sys
del sys
_time = time.time
_sleep = time.sleep
del time
still-seeking-elightenment-ly yours
---Tom
More information about the Python-list
mailing list