Where to import modules
<p>Lets say I have a module called <strong>device</strong> which contains a class called <strong>ConfigureDevice</strong>. Lets also say that I have a module called <strong>comports</strong> which defines my com ports in a class called <strong>ComPorts</strong> (enum in C). </p>

<p>Now, lets say that the constructor for <strong>ConfigureDevice</strong> takes an argument called comPorts. The question is, should I import <strong>comports</strong> at the beginning of the <strong>device</strong> module or should the code creating <strong>ConfigureDevice</strong> make this import?</p>

<p>So, should <strong>import comports</strong> occur here:</p>

<pre><code># device module
import serialwriter
import comports

class ConfigureDevice:
    def __init__(self, comPort):
        self.serialWriter = serialwriter.SerialWriter(comPort)
</code></pre>

<p>Or should I import it in the code that creates ConfigureDevice, like this:</p>

<pre><code>import device
import comports

...

device.ConfigureDevice(comports.ComPorts.COM_1)
</code></pre>
