.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/basic/using_extensions.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_basic_using_extensions.py: Using Extensions ---------------- A simple example using the spydrnet_extension module to illustrate the extension of SpyDrNet IR classes. The .spydrnet file contains: .. code-block:: spydrnet_extension which extends both Element and FirstClassElement, two base classes for SpyDrNet IR objects. Here we import Element and FirstClassElement both from their respective modules and from the spydrnet.ir directory. The first will not be extended while the latter will be. .. code-block:: from spydrnet.ir.element import Element from spydrnet.ir.first_class_element import FirstClassElement from spydrnet.ir import Element as ElementExtended from spydrnet.ir import FirstClassElement as FirstClassElementExtended Then we list the attributes and methods found in the extended version but not in the original versions of the classes. .. code-block:: print("ElementExtended:") print(" ",list(attribute for attribute in dir(ElementExtended) if attribute not in list(thing for thing in dir(Element)))) print("FirstClassElementExtended:") print(" ",list(attribute for attribute in dir(FirstClassElementExtended) if attribute not in list(thing for thing in dir(FirstClassElement)))) We can also simply print lists of the attributes and methods found in each class. One can see that the extended class truly is extended. .. code-block:: print("Element: ",list(attribute for attribute in dir(Element))) print("ElementExtened: ", list(attribute for attribute in dir(ElementExtended))) print("") print("FirstClassElement: ",list(attribute for attribute in dir(FirstClassElement))) print("FirstClassElementExtended: ",list(attribute for attribute in dir(FirstClassElementExtended))) **See full source code below** .. GENERATED FROM PYTHON SOURCE LINES 45-59 .. code-block:: default from spydrnet.ir.element import Element from spydrnet.ir.first_class_element import FirstClassElement from spydrnet.ir import Element as ElementExtended from spydrnet.ir import FirstClassElement as FirstClassElementExtended print("ElementExtended:") print("\t",list(attribute for attribute in dir(ElementExtended) if attribute not in list(thing for thing in dir(Element)))) print("FirstClassElementExtended:") print("\t",list(attribute for attribute in dir(FirstClassElementExtended) if attribute not in list(thing for thing in dir(FirstClassElement)))) print("Element: ",list(attribute for attribute in dir(Element))) print("ElementExtened: ", list(attribute for attribute in dir(ElementExtended))) print("") print("FirstClassElement: ",list(attribute for attribute in dir(FirstClassElement))) print("FirstClassElementExtended: ",list(attribute for attribute in dir(FirstClassElementExtended))) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_basic_using_extensions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: using_extensions.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: using_extensions.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_