import json

class StringReprJSONEncoder(json.JSONEncoder):
    def default(self, o):
        try:
            return repr(o)
        except:
            return '[unserializable]'


def filter_dict(data, filter_keys):
    # filter_keys = set(data.keys())
    for key in filter_keys:
        if data.has_key(key):
            data[key] = "[FILTERED]"
    return data

import json

class StringReprJSONEncoder(json.JSONEncoder):
    def default(self, o):
        try:
            return repr(o)
        except:
            return '[unserializable]'


def filter_dict(data, filter_keys):
    # filter_keys = set(data.keys())
    for key in filter_keys:
        if key in data:
            data[key] = "[FILTERED]"
    return data

Remove has_key to ensure python3 compatibility
Remove has_key to ensure python3 compatibility

  import json
  
  class StringReprJSONEncoder(json.JSONEncoder):
      def default(self, o):
          try:
              return repr(o)
          except:
              return '[unserializable]'
  
  
  def filter_dict(data, filter_keys):
      # filter_keys = set(data.keys())
      for key in filter_keys:
-         if data.has_key(key):
+         if key in data:
              data[key] = "[FILTERED]"
      return data
  
Remove has_key to ensure python3 compatibility
## Code Before:
import json

class StringReprJSONEncoder(json.JSONEncoder):
    def default(self, o):
        try:
            return repr(o)
        except:
            return '[unserializable]'


def filter_dict(data, filter_keys):
    # filter_keys = set(data.keys())
    for key in filter_keys:
        if data.has_key(key):
            data[key] = "[FILTERED]"
    return data

## Instruction:
Remove has_key to ensure python3 compatibility
## Code After:
import json

class StringReprJSONEncoder(json.JSONEncoder):
    def default(self, o):
        try:
            return repr(o)
        except:
            return '[unserializable]'


def filter_dict(data, filter_keys):
    # filter_keys = set(data.keys())
    for key in filter_keys:
        if key in data:
            data[key] = "[FILTERED]"
    return data
