package in python with inheritance












0















I know that this argument is trivial and treated in a lot of post, but I've read it and I'm still don't have clear the idea about how from a folder can be treated as package...
take this example (I know that there is the *rc files that make the same result .. )
I have defined a base class named basequalityplot in which I've defined al the things that is necessary to customize a plot (suction in which I've defined the common parameter (steady or variable) , an update the rcParams ) in a class name quality plot, which contain the base class and more ...:
the complete class named basequalityplot.py is reported in: enter link description here



the base module contains the derived classes ... often repetitive .. and I will report just one :



 import sys
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
from matplotlib.axes import Axes
from cycler import cycler
from matplotlib import cm
from collections import OrderedDict
from matplotlib.ticker import AutoMinorLocator
from basequalityplot import BasePlot

#######################################################################
#######################################################################

class Standard(BasePlot):

def __init__(self,**kwargs):

self.parameters = kwargs

if 'box' not in self.parameters.keys():
self.parameters['box'] = '#AAAAAA'
if 'axeslabel' not in self.parameters.keys():
self.parameters['axeslabel'] = '#AAAAAA'
if 'axes.linewidth' not in self.parameters.keys():
self.parameters['axes.linewidth'] = 0.7
if 'xtickcolor' not in self.parameters.keys():
self.parameters['xtickcolor'] ='#AAAAAA'
if 'ytickcolor' not in self.parameters.keys():
self.parameters['ytickcolor'] = 'gray'
if 'gridcolor' not in self.parameters.keys():
self.parameters['gridcolor'] = 'gray' #'#AAAAAA' #'#dddddd'
if 'font' not in self.parameters.keys():
self.parameters['font'] = 'serif'
if 'fontstyle' not in self.parameters.keys():
self.parameters['fontstyle'] = 'italic'
if 'fontsize' not in self.parameters.keys():
self.parameters['fontsize'] = 10.0
if 'legendfontsize' not in self.parameters.keys():
self.parameters['legendfontsize'] =10.0
if 'legendEdgeColor' not in self.parameters.keys():
self.parameters['legendEdgeColor'] = '#AAAAAA' #'#dddddd'
if 'scheme' not in self.parameters.keys():
self.parameters['scheme'] = 'nb'
if 'cycle' not in self.parameters.keys():
self.parameters['cycle'] = self.cycle('0')
if 'axes.linewidth' not in self.parameters.keys():
self.parameters['axes.linewidth'] = 0.7
if 'grid.dashes' not in self.parameters.keys():
self.parameters['grid.dashes'] = (5,5)
if 'grid.linestyle' not in self.parameters.keys():
self.parameters['grid.linestyle'] = '--'
if 'linestyle' not in self.parameters.keys():
self.parameters['linestyle'] = self.linestyles('paper')
if 'cycle' not in self.parameters.keys():
self.parameters['cycle'] = self.cycle('0')
if 'grid.alpha' not in self.parameters.keys():
self.parameters['grid.alpha'] = '1'
if 'grid.linewidth' not in self.parameters.keys():
self.parameters['grid.linewidth'] = 0.7


self.parameters.update(kwargs)

super().__init__(**self.parameters)


well ... I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



I've tried to create a folder named qualityPlot



and then from a script in subdirectory try to import qualityPlot as is usually for import packjage .. but this doesn't works....
May somebody help me ? :(










share|improve this question





























    0















    I know that this argument is trivial and treated in a lot of post, but I've read it and I'm still don't have clear the idea about how from a folder can be treated as package...
    take this example (I know that there is the *rc files that make the same result .. )
    I have defined a base class named basequalityplot in which I've defined al the things that is necessary to customize a plot (suction in which I've defined the common parameter (steady or variable) , an update the rcParams ) in a class name quality plot, which contain the base class and more ...:
    the complete class named basequalityplot.py is reported in: enter link description here



    the base module contains the derived classes ... often repetitive .. and I will report just one :



     import sys
    import os
    import matplotlib
    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.ticker import MultipleLocator, FormatStrFormatter
    from matplotlib.axes import Axes
    from cycler import cycler
    from matplotlib import cm
    from collections import OrderedDict
    from matplotlib.ticker import AutoMinorLocator
    from basequalityplot import BasePlot

    #######################################################################
    #######################################################################

    class Standard(BasePlot):

    def __init__(self,**kwargs):

    self.parameters = kwargs

    if 'box' not in self.parameters.keys():
    self.parameters['box'] = '#AAAAAA'
    if 'axeslabel' not in self.parameters.keys():
    self.parameters['axeslabel'] = '#AAAAAA'
    if 'axes.linewidth' not in self.parameters.keys():
    self.parameters['axes.linewidth'] = 0.7
    if 'xtickcolor' not in self.parameters.keys():
    self.parameters['xtickcolor'] ='#AAAAAA'
    if 'ytickcolor' not in self.parameters.keys():
    self.parameters['ytickcolor'] = 'gray'
    if 'gridcolor' not in self.parameters.keys():
    self.parameters['gridcolor'] = 'gray' #'#AAAAAA' #'#dddddd'
    if 'font' not in self.parameters.keys():
    self.parameters['font'] = 'serif'
    if 'fontstyle' not in self.parameters.keys():
    self.parameters['fontstyle'] = 'italic'
    if 'fontsize' not in self.parameters.keys():
    self.parameters['fontsize'] = 10.0
    if 'legendfontsize' not in self.parameters.keys():
    self.parameters['legendfontsize'] =10.0
    if 'legendEdgeColor' not in self.parameters.keys():
    self.parameters['legendEdgeColor'] = '#AAAAAA' #'#dddddd'
    if 'scheme' not in self.parameters.keys():
    self.parameters['scheme'] = 'nb'
    if 'cycle' not in self.parameters.keys():
    self.parameters['cycle'] = self.cycle('0')
    if 'axes.linewidth' not in self.parameters.keys():
    self.parameters['axes.linewidth'] = 0.7
    if 'grid.dashes' not in self.parameters.keys():
    self.parameters['grid.dashes'] = (5,5)
    if 'grid.linestyle' not in self.parameters.keys():
    self.parameters['grid.linestyle'] = '--'
    if 'linestyle' not in self.parameters.keys():
    self.parameters['linestyle'] = self.linestyles('paper')
    if 'cycle' not in self.parameters.keys():
    self.parameters['cycle'] = self.cycle('0')
    if 'grid.alpha' not in self.parameters.keys():
    self.parameters['grid.alpha'] = '1'
    if 'grid.linewidth' not in self.parameters.keys():
    self.parameters['grid.linewidth'] = 0.7


    self.parameters.update(kwargs)

    super().__init__(**self.parameters)


    well ... I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



    I've tried to create a folder named qualityPlot



    and then from a script in subdirectory try to import qualityPlot as is usually for import packjage .. but this doesn't works....
    May somebody help me ? :(










    share|improve this question



























      0












      0








      0








      I know that this argument is trivial and treated in a lot of post, but I've read it and I'm still don't have clear the idea about how from a folder can be treated as package...
      take this example (I know that there is the *rc files that make the same result .. )
      I have defined a base class named basequalityplot in which I've defined al the things that is necessary to customize a plot (suction in which I've defined the common parameter (steady or variable) , an update the rcParams ) in a class name quality plot, which contain the base class and more ...:
      the complete class named basequalityplot.py is reported in: enter link description here



      the base module contains the derived classes ... often repetitive .. and I will report just one :



       import sys
      import os
      import matplotlib
      import matplotlib.pyplot as plt
      import numpy as np
      from matplotlib.ticker import MultipleLocator, FormatStrFormatter
      from matplotlib.axes import Axes
      from cycler import cycler
      from matplotlib import cm
      from collections import OrderedDict
      from matplotlib.ticker import AutoMinorLocator
      from basequalityplot import BasePlot

      #######################################################################
      #######################################################################

      class Standard(BasePlot):

      def __init__(self,**kwargs):

      self.parameters = kwargs

      if 'box' not in self.parameters.keys():
      self.parameters['box'] = '#AAAAAA'
      if 'axeslabel' not in self.parameters.keys():
      self.parameters['axeslabel'] = '#AAAAAA'
      if 'axes.linewidth' not in self.parameters.keys():
      self.parameters['axes.linewidth'] = 0.7
      if 'xtickcolor' not in self.parameters.keys():
      self.parameters['xtickcolor'] ='#AAAAAA'
      if 'ytickcolor' not in self.parameters.keys():
      self.parameters['ytickcolor'] = 'gray'
      if 'gridcolor' not in self.parameters.keys():
      self.parameters['gridcolor'] = 'gray' #'#AAAAAA' #'#dddddd'
      if 'font' not in self.parameters.keys():
      self.parameters['font'] = 'serif'
      if 'fontstyle' not in self.parameters.keys():
      self.parameters['fontstyle'] = 'italic'
      if 'fontsize' not in self.parameters.keys():
      self.parameters['fontsize'] = 10.0
      if 'legendfontsize' not in self.parameters.keys():
      self.parameters['legendfontsize'] =10.0
      if 'legendEdgeColor' not in self.parameters.keys():
      self.parameters['legendEdgeColor'] = '#AAAAAA' #'#dddddd'
      if 'scheme' not in self.parameters.keys():
      self.parameters['scheme'] = 'nb'
      if 'cycle' not in self.parameters.keys():
      self.parameters['cycle'] = self.cycle('0')
      if 'axes.linewidth' not in self.parameters.keys():
      self.parameters['axes.linewidth'] = 0.7
      if 'grid.dashes' not in self.parameters.keys():
      self.parameters['grid.dashes'] = (5,5)
      if 'grid.linestyle' not in self.parameters.keys():
      self.parameters['grid.linestyle'] = '--'
      if 'linestyle' not in self.parameters.keys():
      self.parameters['linestyle'] = self.linestyles('paper')
      if 'cycle' not in self.parameters.keys():
      self.parameters['cycle'] = self.cycle('0')
      if 'grid.alpha' not in self.parameters.keys():
      self.parameters['grid.alpha'] = '1'
      if 'grid.linewidth' not in self.parameters.keys():
      self.parameters['grid.linewidth'] = 0.7


      self.parameters.update(kwargs)

      super().__init__(**self.parameters)


      well ... I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



      I've tried to create a folder named qualityPlot



      and then from a script in subdirectory try to import qualityPlot as is usually for import packjage .. but this doesn't works....
      May somebody help me ? :(










      share|improve this question
















      I know that this argument is trivial and treated in a lot of post, but I've read it and I'm still don't have clear the idea about how from a folder can be treated as package...
      take this example (I know that there is the *rc files that make the same result .. )
      I have defined a base class named basequalityplot in which I've defined al the things that is necessary to customize a plot (suction in which I've defined the common parameter (steady or variable) , an update the rcParams ) in a class name quality plot, which contain the base class and more ...:
      the complete class named basequalityplot.py is reported in: enter link description here



      the base module contains the derived classes ... often repetitive .. and I will report just one :



       import sys
      import os
      import matplotlib
      import matplotlib.pyplot as plt
      import numpy as np
      from matplotlib.ticker import MultipleLocator, FormatStrFormatter
      from matplotlib.axes import Axes
      from cycler import cycler
      from matplotlib import cm
      from collections import OrderedDict
      from matplotlib.ticker import AutoMinorLocator
      from basequalityplot import BasePlot

      #######################################################################
      #######################################################################

      class Standard(BasePlot):

      def __init__(self,**kwargs):

      self.parameters = kwargs

      if 'box' not in self.parameters.keys():
      self.parameters['box'] = '#AAAAAA'
      if 'axeslabel' not in self.parameters.keys():
      self.parameters['axeslabel'] = '#AAAAAA'
      if 'axes.linewidth' not in self.parameters.keys():
      self.parameters['axes.linewidth'] = 0.7
      if 'xtickcolor' not in self.parameters.keys():
      self.parameters['xtickcolor'] ='#AAAAAA'
      if 'ytickcolor' not in self.parameters.keys():
      self.parameters['ytickcolor'] = 'gray'
      if 'gridcolor' not in self.parameters.keys():
      self.parameters['gridcolor'] = 'gray' #'#AAAAAA' #'#dddddd'
      if 'font' not in self.parameters.keys():
      self.parameters['font'] = 'serif'
      if 'fontstyle' not in self.parameters.keys():
      self.parameters['fontstyle'] = 'italic'
      if 'fontsize' not in self.parameters.keys():
      self.parameters['fontsize'] = 10.0
      if 'legendfontsize' not in self.parameters.keys():
      self.parameters['legendfontsize'] =10.0
      if 'legendEdgeColor' not in self.parameters.keys():
      self.parameters['legendEdgeColor'] = '#AAAAAA' #'#dddddd'
      if 'scheme' not in self.parameters.keys():
      self.parameters['scheme'] = 'nb'
      if 'cycle' not in self.parameters.keys():
      self.parameters['cycle'] = self.cycle('0')
      if 'axes.linewidth' not in self.parameters.keys():
      self.parameters['axes.linewidth'] = 0.7
      if 'grid.dashes' not in self.parameters.keys():
      self.parameters['grid.dashes'] = (5,5)
      if 'grid.linestyle' not in self.parameters.keys():
      self.parameters['grid.linestyle'] = '--'
      if 'linestyle' not in self.parameters.keys():
      self.parameters['linestyle'] = self.linestyles('paper')
      if 'cycle' not in self.parameters.keys():
      self.parameters['cycle'] = self.cycle('0')
      if 'grid.alpha' not in self.parameters.keys():
      self.parameters['grid.alpha'] = '1'
      if 'grid.linewidth' not in self.parameters.keys():
      self.parameters['grid.linewidth'] = 0.7


      self.parameters.update(kwargs)

      super().__init__(**self.parameters)


      well ... I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



      I've tried to create a folder named qualityPlot



      and then from a script in subdirectory try to import qualityPlot as is usually for import packjage .. but this doesn't works....
      May somebody help me ? :(







      python matplotlib






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 9:47









      Devendra Bhat

      5471715




      5471715










      asked Nov 16 '18 at 9:29









      Drudox lebowskyDrudox lebowsky

      504113




      504113
























          3 Answers
          3






          active

          oldest

          votes


















          1














          To use modules in Python




          • Ensure the __init__.py file exists in the directory (note the underscores)

          • Note that both the folder name and the file name are part of the module

          • Make sure Python will find the path (say with PYTHONPATH)


          In your example,



          from basequalityplot import BasePlot



          This expects to find a file basequalityplot.py in the current directory (or elsewhere directly on the python path, or a compiled version). Inside that file it expects to find the class BasePlot.




          I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



          I've tried to create a folder named qualityPlot




          What you've described here doesn't quite match your example code. If you have a folder structure



          qualityPlot/
          __init__.py
          basequalityplot.py
          qualityplot.py


          I would expect the import statement to read



          from qualityPlot.qualityplot import BasePlot


          6.4 in the Python Tutorial has a useful example
          https://docs.python.org/3/tutorial/modules.html#packages






          share|improve this answer

































            0














            You need to create a (probably empty) __init__.py in the directory.



            Note that in Python there is no requirement or expectation for each class to be in its own file, so it's fine if you just want to create your child classes in the same file.



            Note also, a much better pattern for your parameters is to define a dictionary of defaults, and then update it with whatever comes in from kwargs:



            self.parameters = {
            'box': '#AAAAAA',
            'axeslabel': '#AAAAAA',
            'axes.linewidth': 0.7,
            'xtickcolor': '#AAAAAA',
            'ytickcolor': 'gray',
            ...
            }
            self.parameters.update(kwargs)





            share|improve this answer
























            • I've tried to create an empty init.py but the thisgs is the same

              – Drudox lebowsky
              Nov 16 '18 at 9:52





















            0














            You need to "help" the import by telling it where to look:



            import sys
            sys.path.append("C:/path/to/your/qualityplot/folder")
            import qualityPlot


            It should work. I use that to write different programs placed at different places but calling to the same common library (personal stuff with maths and graphs mostly).






            share|improve this answer
























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334919%2fpackage-in-python-with-inheritance%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              To use modules in Python




              • Ensure the __init__.py file exists in the directory (note the underscores)

              • Note that both the folder name and the file name are part of the module

              • Make sure Python will find the path (say with PYTHONPATH)


              In your example,



              from basequalityplot import BasePlot



              This expects to find a file basequalityplot.py in the current directory (or elsewhere directly on the python path, or a compiled version). Inside that file it expects to find the class BasePlot.




              I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



              I've tried to create a folder named qualityPlot




              What you've described here doesn't quite match your example code. If you have a folder structure



              qualityPlot/
              __init__.py
              basequalityplot.py
              qualityplot.py


              I would expect the import statement to read



              from qualityPlot.qualityplot import BasePlot


              6.4 in the Python Tutorial has a useful example
              https://docs.python.org/3/tutorial/modules.html#packages






              share|improve this answer






























                1














                To use modules in Python




                • Ensure the __init__.py file exists in the directory (note the underscores)

                • Note that both the folder name and the file name are part of the module

                • Make sure Python will find the path (say with PYTHONPATH)


                In your example,



                from basequalityplot import BasePlot



                This expects to find a file basequalityplot.py in the current directory (or elsewhere directly on the python path, or a compiled version). Inside that file it expects to find the class BasePlot.




                I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



                I've tried to create a folder named qualityPlot




                What you've described here doesn't quite match your example code. If you have a folder structure



                qualityPlot/
                __init__.py
                basequalityplot.py
                qualityplot.py


                I would expect the import statement to read



                from qualityPlot.qualityplot import BasePlot


                6.4 in the Python Tutorial has a useful example
                https://docs.python.org/3/tutorial/modules.html#packages






                share|improve this answer




























                  1












                  1








                  1







                  To use modules in Python




                  • Ensure the __init__.py file exists in the directory (note the underscores)

                  • Note that both the folder name and the file name are part of the module

                  • Make sure Python will find the path (say with PYTHONPATH)


                  In your example,



                  from basequalityplot import BasePlot



                  This expects to find a file basequalityplot.py in the current directory (or elsewhere directly on the python path, or a compiled version). Inside that file it expects to find the class BasePlot.




                  I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



                  I've tried to create a folder named qualityPlot




                  What you've described here doesn't quite match your example code. If you have a folder structure



                  qualityPlot/
                  __init__.py
                  basequalityplot.py
                  qualityplot.py


                  I would expect the import statement to read



                  from qualityPlot.qualityplot import BasePlot


                  6.4 in the Python Tutorial has a useful example
                  https://docs.python.org/3/tutorial/modules.html#packages






                  share|improve this answer















                  To use modules in Python




                  • Ensure the __init__.py file exists in the directory (note the underscores)

                  • Note that both the folder name and the file name are part of the module

                  • Make sure Python will find the path (say with PYTHONPATH)


                  In your example,



                  from basequalityplot import BasePlot



                  This expects to find a file basequalityplot.py in the current directory (or elsewhere directly on the python path, or a compiled version). Inside that file it expects to find the class BasePlot.




                  I would like to contain basequalityplot.py and qualityplot.py in the same directory (where qualityplot is the module that contain the class that I want use .. in this case I've report just the standard one)



                  I've tried to create a folder named qualityPlot




                  What you've described here doesn't quite match your example code. If you have a folder structure



                  qualityPlot/
                  __init__.py
                  basequalityplot.py
                  qualityplot.py


                  I would expect the import statement to read



                  from qualityPlot.qualityplot import BasePlot


                  6.4 in the Python Tutorial has a useful example
                  https://docs.python.org/3/tutorial/modules.html#packages







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 16 '18 at 13:58

























                  answered Nov 16 '18 at 11:01









                  Adam BurkeAdam Burke

                  945




                  945

























                      0














                      You need to create a (probably empty) __init__.py in the directory.



                      Note that in Python there is no requirement or expectation for each class to be in its own file, so it's fine if you just want to create your child classes in the same file.



                      Note also, a much better pattern for your parameters is to define a dictionary of defaults, and then update it with whatever comes in from kwargs:



                      self.parameters = {
                      'box': '#AAAAAA',
                      'axeslabel': '#AAAAAA',
                      'axes.linewidth': 0.7,
                      'xtickcolor': '#AAAAAA',
                      'ytickcolor': 'gray',
                      ...
                      }
                      self.parameters.update(kwargs)





                      share|improve this answer
























                      • I've tried to create an empty init.py but the thisgs is the same

                        – Drudox lebowsky
                        Nov 16 '18 at 9:52


















                      0














                      You need to create a (probably empty) __init__.py in the directory.



                      Note that in Python there is no requirement or expectation for each class to be in its own file, so it's fine if you just want to create your child classes in the same file.



                      Note also, a much better pattern for your parameters is to define a dictionary of defaults, and then update it with whatever comes in from kwargs:



                      self.parameters = {
                      'box': '#AAAAAA',
                      'axeslabel': '#AAAAAA',
                      'axes.linewidth': 0.7,
                      'xtickcolor': '#AAAAAA',
                      'ytickcolor': 'gray',
                      ...
                      }
                      self.parameters.update(kwargs)





                      share|improve this answer
























                      • I've tried to create an empty init.py but the thisgs is the same

                        – Drudox lebowsky
                        Nov 16 '18 at 9:52
















                      0












                      0








                      0







                      You need to create a (probably empty) __init__.py in the directory.



                      Note that in Python there is no requirement or expectation for each class to be in its own file, so it's fine if you just want to create your child classes in the same file.



                      Note also, a much better pattern for your parameters is to define a dictionary of defaults, and then update it with whatever comes in from kwargs:



                      self.parameters = {
                      'box': '#AAAAAA',
                      'axeslabel': '#AAAAAA',
                      'axes.linewidth': 0.7,
                      'xtickcolor': '#AAAAAA',
                      'ytickcolor': 'gray',
                      ...
                      }
                      self.parameters.update(kwargs)





                      share|improve this answer













                      You need to create a (probably empty) __init__.py in the directory.



                      Note that in Python there is no requirement or expectation for each class to be in its own file, so it's fine if you just want to create your child classes in the same file.



                      Note also, a much better pattern for your parameters is to define a dictionary of defaults, and then update it with whatever comes in from kwargs:



                      self.parameters = {
                      'box': '#AAAAAA',
                      'axeslabel': '#AAAAAA',
                      'axes.linewidth': 0.7,
                      'xtickcolor': '#AAAAAA',
                      'ytickcolor': 'gray',
                      ...
                      }
                      self.parameters.update(kwargs)






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 16 '18 at 9:35









                      Daniel RosemanDaniel Roseman

                      458k42594653




                      458k42594653













                      • I've tried to create an empty init.py but the thisgs is the same

                        – Drudox lebowsky
                        Nov 16 '18 at 9:52





















                      • I've tried to create an empty init.py but the thisgs is the same

                        – Drudox lebowsky
                        Nov 16 '18 at 9:52



















                      I've tried to create an empty init.py but the thisgs is the same

                      – Drudox lebowsky
                      Nov 16 '18 at 9:52







                      I've tried to create an empty init.py but the thisgs is the same

                      – Drudox lebowsky
                      Nov 16 '18 at 9:52













                      0














                      You need to "help" the import by telling it where to look:



                      import sys
                      sys.path.append("C:/path/to/your/qualityplot/folder")
                      import qualityPlot


                      It should work. I use that to write different programs placed at different places but calling to the same common library (personal stuff with maths and graphs mostly).






                      share|improve this answer




























                        0














                        You need to "help" the import by telling it where to look:



                        import sys
                        sys.path.append("C:/path/to/your/qualityplot/folder")
                        import qualityPlot


                        It should work. I use that to write different programs placed at different places but calling to the same common library (personal stuff with maths and graphs mostly).






                        share|improve this answer


























                          0












                          0








                          0







                          You need to "help" the import by telling it where to look:



                          import sys
                          sys.path.append("C:/path/to/your/qualityplot/folder")
                          import qualityPlot


                          It should work. I use that to write different programs placed at different places but calling to the same common library (personal stuff with maths and graphs mostly).






                          share|improve this answer













                          You need to "help" the import by telling it where to look:



                          import sys
                          sys.path.append("C:/path/to/your/qualityplot/folder")
                          import qualityPlot


                          It should work. I use that to write different programs placed at different places but calling to the same common library (personal stuff with maths and graphs mostly).







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 16 '18 at 11:00









                          GuimouteGuimoute

                          695211




                          695211






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334919%2fpackage-in-python-with-inheritance%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Bressuire

                              Vorschmack

                              Quarantine