title: Import module functions as staticmethods into a class
body: <p>I have a python module 
  <strong>helpers.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>
  def str_to_num(s: str):
      '''Converts to int if possible else converts to float if possible
      Returns back the string if not possible to convert to a number.
      '''
      # NOTE: These are not really funcs, but classes.
      funcs = [int, float]
  
      for func in funcs:
          try:
              res = func(s)
              break
          except ValueError:
              continue
      else:
          res = s
  
      return(res)
  
  </code></pre>
  
  <p>I have another module <strong>string_number.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>from helpers import str_to_num
  
  class StringNumber:
  
      def __init__(self, s):
          self.s = s
  
      str_to_num = str_to_num
  
      @property
      def value(self):
          return(self.str_to_num(self.s))
  
      def __repr__(self):
          return(f'{self.__class__.__name__}({repr(self.s)})')
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; from string_number import StringNumber
  &gt;&gt;&gt; sn = StringNumber(1)
  &gt;&gt;&gt; sn.value 
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "string_number.py", line 19, in value
      return(self.str_to_num(self.s))
  TypeError: str_to_num() takes 1 positional argument but 2 were given
  </code></pre>
  
  <p>However this works when accessing the function from the class:</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; StringNumber.str_to_num(1)
  1
  </code></pre>
  
  <p><strong>Q.1</strong>: Why does the <code>str_to_num</code> attribute require two arguments when accessing it from the instance? Is <strong>self</strong> being passed to it? If so, why?</p>
  
  <p>Now, I know I can add modify the <code>__init__</code> method to make it an attribute of the instance</p>
  
  <pre class="lang-py prettyprint-override"><code>def __init__(self, s):
      self.s = s
      self.str_to_num = str_to_num
  </code></pre>
  
  <p>Further, I can resolve this by making a class of Helper functions and then inheriting from it.</p>
  
  <pre class="lang-py prettyprint-override"><code>from helpers import str_to_num
  
  class Helper:
      @staticmethod
      def str_to_num(s):
          return(str_to_num(s))
  
  
  class StringNumber(Helper):
  
      def __init__(self, s):
          self.s = s
  
      @property
      def value(self):
          return(self.str_to_num(self.s))
  
      def __repr__(self):
          return(f'{self.__class__.__name__}({repr(self.s)})')
  
  </code></pre>
  
  <p><strong>Q: 2</strong> Is there a way to make module functions, staticmethods of a class, without using inheritance? Or is this a really bad practice?</p>
  
  <p><strong>Q: 3</strong> Assuming I had a <strong>helpers.py</strong> module, with a large amount of module functions. To incorporate them as staticmethods into my class, what would be the best way, without making a separate <code>Helper</code> class?</p>