Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I encountering an ImportError when I try to 're-import' a module?
    primarykey
    data
    text
    <p>I have a series of python modules written which are held in the same directory and I am having trouble with an ImportError.</p> <p>The three modules I am using are <code>draw_menu.py</code>, <code>errors.py</code> and <code>file_operations.py</code>.</p> <p>In <code>errors.py</code> I requires a list of error codes, I am using a custom method defined in <code>file_operations.py</code> to open a file containing the codes therefore I am using <code>import file_operations</code> just below the she-bang (above the class definition).</p> <p>In <code>file_operations.py</code> I use a method defined in <code>error.py</code> to print error messages upon errors (e.g. file not found etc.). I therefore <code>import errors</code> in the same way here.</p> <p>The above has been working fine but when I come to using <code>draw_menu.py</code> which uses a file to define the options in an ascii menu (therefore I am using <code>import file_operations</code>) an ImportError is encountered. </p> <p><code>ImportError: cannot import name file_operations</code></p> <p>I understand that this is because the 'import tree' if you like flows as follows:</p> <p><code>draw_menu</code> &lt;- <code>file_operations</code> &lt;- <code>errors</code> &lt;- <code>file_operations</code></p> <p>It is important that each module can be used individually, why is this an issue and how can I overcome this without removing <code>import file_operations</code> from <code>errors.py</code>?</p> <p>Thankyou </p> <p>Tom</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload