I\'ve seen some Python programmers use the following style fairly consistently (we\'ll call it style 1):
import some_module
# Use some_module.some_identifier in
I tend to use only a few members of each module, so there's a lot of
from john import cleese
from terry import jones, gilliam
in my code. I'll import whole modules (such as os
or wx
) if I expect to be using most of the module and the module name is short. I'll also import whole modules if there is a name conflict or I want to remind the reader what that function is associated with.
import michael
import sarah
import wave
gov_speech = wave.open(sarah.palin.speechfile)
parrot_sketch = wave.open(michael.palin.justresting)
(I could use from wave import open as wave_open
, but I figure that wave.open
will be more familiar to the reader.