code: def namespaced_query_string(d, prefix=""):
      
      qs = {}
      prefixed = lambda k: prefix and "%s[%s]" % (prefix, k) or k
      for key, value in six.iteritems(d):
          if isinstance(value, dict):
              qs.update(namespaced_query_string(value, prefix=key))
          else:
              qs[prefixed(key)] = value
      return qs
docs: Transform a nested dict into a string with namespaced query params.
  
      >>> namespaced_query_string({
      ...  'oauth_token': 'foo',
      ...  'track': {'title': 'bar', 'sharing': 'private'}}) == {
      ...      'track[sharing]': 'private',
      ...      'oauth_token': 'foo',
      ...      'track[title]': 'bar'}  # doctest:+ELLIPSIS
      True