<h1>Evennia API<aclass="headerlink"href="#evennia-api"title="Permalink to this headline">¶</a></h1>
<p>Evennia makes much of its programming tools available directly from the top-level <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> package. This is often referred to as Evennia’s “flat” <aclass="reference external"href="https://en.wikipedia.org/wiki/Application_programming_interface">Application Programming Interface</a> (API). The flat API tries to collect and bring the most commonly used resources to the front in a way where everything is available at a glance (in a flat display), making it a good place to start to learn Evennia.</p>
<blockquote>
<div><p>Evennia’s flat (and full) API can be perused through the auto-generated <aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia">API Library refence</a>.</p>
</div></blockquote>
<p>A good, interactive way to explore the flat API is to use <aclass="reference external"href="http://ipython.org/">IPython</a>, a more flexible version of the default Python shell. Inside your virtual environment you can install IPython simply by</p>
<p>That is, write <codeclass="docutils literal notranslate"><spanclass="pre">evennia.</span></code> and press the TAB key. What pops up is the contents of the <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> top-level package - in other words <aclass="reference external"href="https://github.com/evennia/evennia/blob/master/evennia#the-flat-api">the “flat” API</a>.</p>
<p>Starting to write the name of an API entity and pressing <codeclass="docutils literal notranslate"><spanclass="pre"><TAB></span></code> will auto-complete the name. Adding a question mark (<codeclass="docutils literal notranslate"><spanclass="pre">?</span></code>) to its name will show you its documentation. Append <codeclass="docutils literal notranslate"><spanclass="pre">??</span></code> to get the actual source code. This way you can quickly explore Evennia and see what is available.</p>
<h2>To remember when importing from <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code><aclass="headerlink"href="#to-remember-when-importing-from-evennia"title="Permalink to this headline">¶</a></h2>
<p>Properties on the root of the <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> package are <em>not</em> modules in their own right. They are just shortcut properties stored in the <codeclass="docutils literal notranslate"><spanclass="pre">evennia/__init__.py</span></code> module. That means that you cannot use dot-notation to <codeclass="docutils literal notranslate"><spanclass="pre">import</span></code> nested module-names over <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code>. The rule of thumb is that you cannot use <codeclass="docutils literal notranslate"><spanclass="pre">import</span></code> for more than one level down. Hence you can do</p>
<p>This will give you an <codeclass="docutils literal notranslate"><spanclass="pre">ImportError</span></code> telling you that the module <codeclass="docutils literal notranslate"><spanclass="pre">default_cmds</span></code> cannot be found - this is becasue <codeclass="docutils literal notranslate"><spanclass="pre">default_cmds</span></code> is just a <em>variable</em> stored in <codeclass="docutils literal notranslate"><spanclass="pre">evennia.__init__.py</span></code>; this cannot be imported from. If you really want full control over which level of package you import you can always bypass the root package and import directly from from the real location. For example <codeclass="docutils literal notranslate"><spanclass="pre">evennia.DefaultObject</span></code> is a shortcut to <codeclass="docutils literal notranslate"><spanclass="pre">evennia.objects.objects.DefaultObject</span></code>. Using this full path will have the import mechanism work normally. See <codeclass="docutils literal notranslate"><spanclass="pre">evennia/__init__.py</span></code> to see where the package imports from.</p>
<li><aclass="reference internal"href="#to-remember-when-importing-from-evennia">To remember when importing from <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code></a></li>