Assign class' staticmethods in static variable in python
<p>I have the following class which produces an error:</p>

<pre><code>class MyClass(object):

    QUERIES_AGGS = {
        'query3': {
            "query": MyClass._make_basic_query,
            'aggregations': MyClass._make_query_three_aggregations,
            'aggregation_transformations': MyClass._make_query_three_transformations
        }
    }


    @staticmethod
    def _make_basic_query():
       #some code here

   @staticmethod
   def _make_query_three_aggregations():
        #some code here

   @staticmethod
   def _make_query_three_transformations(aggs):
        #some code here
</code></pre>

<p>For now it won't recognize MyClass. If i remove "MyClass" python won't recognize the functions. I know I could move the static methods from inside the class outside as module functions. Is it possible to keep them inside the class and use them like I am trying?</p>

<p>Change the order so that the dictionary is specified after the methods have been defined. Also don't use <code>MyClass</code> when doing so.</p>

<pre><code>class MyClass(object):

    @staticmethod
    def _make_basic_query():
       #some code here
       pass

    @staticmethod
    def _make_query_three_aggregations():
       #some code here
       pass

    @staticmethod
    def _make_query_three_transformations(aggs):
       #some code here
       pass

    QUERIES_AGGS = {
        'query3': {
            "query": _make_basic_query,
            'aggregations': _make_query_three_aggregations,
            'aggregation_transformations': _make_query_three_transformations
        }
    }
</code></pre>

<p>This works because when in the body of the class declaration, you can reference methods without needing the class type. What you are referencing has to have already been declared though.</p>

python