Paulo da Silva <ps********@esotericaX.ptXwrites:
Hi!
If I have two files .py such as
m.py
from c import *
Best done as either
import c # then use 'x = c.c()'
or
from c import c
Using 'from foo import *' leads to names appearing in your current
namespace that are difficult to track to their origin by reading the
source code.
both using os module where should I put the "import os"? In both
files?
Yes. "import os" does two things of note:
- iff the module is not currently loaded and executed, do so
- bind the module object to the name "os" in the current namespace
The first step means that you're not losing anything by importing the
module wherever it's needed. The second means the module is available
for use within the current namespace.
--
\ "When cryptography is outlawed, bayl bhgynjf jvyy unir |
`\ cevinpl." -- Anonymous |
_o__) |
Ben Finney