
from .base import Logger


class Dynamic(Logger):
    '''Dynamic logger allowing delayed computation of values.'''

    def __getitem__(self, key):
        '''Return value referenced by *key*.

        If the value is a callable, then call it and return the result. In
        addition store the computed result for future use.

        '''
        value = self._mapping[key]
        if callable(value):
            self[key] = value = value()

        return value


import collections

from .base import Logger


class Dynamic(Logger):
    '''Dynamic logger allowing delayed computation of values.'''

    def __getitem__(self, key):
        '''Return value referenced by *key*.

        If the value is a callable, then call it and return the result. In
        addition store the computed result for future use.

        '''
        value = self._mapping[key]
        if isinstance(value, collections.Callable):
            self[key] = value = value()

        return value

Use collections.Callable test for future compatibility.
Use collections.Callable test for future compatibility.

+ 
+ import collections
  
  from .base import Logger
  
  
  class Dynamic(Logger):
      '''Dynamic logger allowing delayed computation of values.'''
  
      def __getitem__(self, key):
          '''Return value referenced by *key*.
  
          If the value is a callable, then call it and return the result. In
          addition store the computed result for future use.
  
          '''
          value = self._mapping[key]
-         if callable(value):
+         if isinstance(value, collections.Callable):
              self[key] = value = value()
  
          return value
  
Use collections.Callable test for future compatibility.
## Code Before:

from .base import Logger


class Dynamic(Logger):
    '''Dynamic logger allowing delayed computation of values.'''

    def __getitem__(self, key):
        '''Return value referenced by *key*.

        If the value is a callable, then call it and return the result. In
        addition store the computed result for future use.

        '''
        value = self._mapping[key]
        if callable(value):
            self[key] = value = value()

        return value

## Instruction:
Use collections.Callable test for future compatibility.
## Code After:

import collections

from .base import Logger


class Dynamic(Logger):
    '''Dynamic logger allowing delayed computation of values.'''

    def __getitem__(self, key):
        '''Return value referenced by *key*.

        If the value is a callable, then call it and return the result. In
        addition store the computed result for future use.

        '''
        value = self._mapping[key]
        if isinstance(value, collections.Callable):
            self[key] = value = value()

        return value
