title: Python - How do you detect that a module has been loaded by custom loader?
body: <p>Before Python-3.3, I detected that a module was loaded by a custom loader with <code>hasattr(mod, '__loader__')</code>.
  After Python-3.3, all modules have the <code>__loader__</code> attribute regardless of being loaded by a custom loader.</p>
  
  <p>Python-2.7, 3.2:</p>
  
  <pre><code>&gt;&gt;&gt; import xml
  &gt;&gt;&gt; hasattr(xml, '__loader__')
  False
  </code></pre>
  
  <p>Python-3.3:</p>
  
  <pre><code>&gt;&gt;&gt; import xml
  &gt;&gt;&gt; hasattr(xml, '__loader__')
  True
  &gt;&gt;&gt; xml.__loader__
  &lt;_frozen_importlib.SourceFileLoader object at ...&gt;
  </code></pre>
  
  <p>How do I detect that a module was loaded by a custom loader?</p>