You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've customized flatten to allow for a two custom delimiters. I needed to be able to create post variables for a PHP api and your flatten function was the simplest thing to customize.
def flatten(o, left='.', right=''):
left = '%s' % left
right = '%s' % right
stack = [(wrap(o).iteritems(), None)]
while stack:
items_iter, parent_key = stack[-1]
for (key, value) in items_iter:
if parent_key is None:
full_key = key
else:
full_key = left.join([parent_key, '%s%s' % (key, right)] )
if value is not unwrap(value):
stack.append((iter(value.items()), full_key))
break
yield full_key, value
else:
stack.pop()
The text was updated successfully, but these errors were encountered:
I've customized flatten to allow for a two custom delimiters. I needed to be able to create post variables for a PHP api and your flatten function was the simplest thing to customize.
The text was updated successfully, but these errors were encountered: