Frozenset bug.
pprintpp.pprint({6,frozenset({78, 32, 342}),8})
fails with
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 94, in pprint
printer.pprint(object)
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 236, in pprint
self._format(object, state)
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 349, in _format
self._format_nested_objects(object, state, typeish=typeish)
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 280, in _format_nested_objects
oneline=True)
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 310, in _write_nested_real
object = _sorted(object)
File "/home/jonathan/.virtualenvs/.../local/lib/python2.7/site-packages/pprintpp.py", line 117, in _sorted
return sorted(iterable)
TypeError: can only compare to a set
(I didn't had time to look further into this issue.)
Weird. I can't recreate that on any of the supported Pythons (2.7, 3.3, PyPy). What's in the set?
Disregard that, I'm an idiot. The issue is that sets can't be compared to non-set things. Testing for this also uncovered a related issue: python 3 gets fussy when trying to sort heterogeneous sets. Fix incoming!
Okay! I've put https://github.com/wolever/safesort out there for comments, and I'll use it for sorting here too once I've got some confirmation that it's not a totally insane thing to do.
ok, nice. :)
btw, is it impossible to establish without the exec in safesort?
On 2014-09-10, at 1:56 PM, Jonathan Slenders [email protected] wrote:
ok, nice. :) btw, is it impossible to establish without the exec in safesort?
Ya, safesort would definitely be possible to implement without exec; there would just be a lot of code duplication, or a pile of less performant function calls. What's the concern about it?=
No real concern, it could be a valid use case. Only it feels like going back in time and have code preprocessors and macros like in C. :)
On 2014-09-10, at 3:23 PM, Jonathan Slenders [email protected] wrote:
No real concern, it could be a valid use case. Only it feels like going back in time and have code preprocessors and macros like in C. :)
That is precisely what it is ;)
Python is wonderful for many things, but it does fall a bit short in preprocessing department :(=