-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: no newlines in base lists #239
Comments
It’s an interesting use case, but pretty printing is a bit complicated in the general case. If you had a PR to implement this it would be strongly considered so long as it doesn’t affect performance of the normal case. |
I'll see what I can do when I get some free time! FYI, for now, my workaround looks like this (I also only want to "flatten" numeric arrays): import re,simplejson
# ...
def jsondump(obj,fp,**kwargs):
s = simplejson.dumps(obj,**kwargs)
for match in re.finditer('\[((?ms)\n|\s|\d|\.|\,|null)*\]',s):
s = s.replace(match.group(0),
match.group(0).replace(' ','').replace('\n',' '))
fp.write(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some content with long and sometimes deeply nested lists (from
np.ndarray.tolist()
). While it is readable to print with newlines for every element, it would IMO be much cleaner to omit newlines in the inner-most list, and replace with spaces. For example,Currently:
Desired:
Would this be considered? Or too much of a special case?
Thanks,
The text was updated successfully, but these errors were encountered: