-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
print()
for tuple should use print()
to stringify its contents
#10233
Comments
print()
for tuples should use print()
to stringify its contentsprint()
for tuple should use print()
to stringify its contents
The reason we do this is that numbers have canonical printed representations, but tuples do not. As soon as we're printing |
This suggests (again) a python-like distinction between |
It's is a bit messier than ideal right now, but there is a somewhat consistent distinction made already. |
I cannot grasp what "canonical" means in this context, but as I read the discussion in #3450, |
By "canonical" I mean not julia-specific. I don't really see the value of printing |
Hex notation is quite annoying when debugging codes dealing with tuples containing unsigned ints. julia> ui, ui_t = uint(123), tuple(uint(456), uint(789))
(0x000000000000007b,(0x00000000000001c8,0x0000000000000315))
julia> show(ui)
0x000000000000007b
julia> print(ui)
123
julia> show(ui_t)
(0x00000000000001c8,0x0000000000000315)
julia> print(ui_t)
(0x00000000000001c8,0x0000000000000315) # (456,789) is much more comprehensible |
Relevant: #7959 |
Even if Julia syntax is used for |
-1 to printing unsigned ints as integers rather than hex |
@johnmyleswhite I think the debate here is: why would |
Let's just print everything in hex – consistency problem solved. |
I can totally understand not wanting to see hex in many cases, but I think that's the only real issue here. Consider another example of the general proposal described by the issue title:
With the proposed change, the second output would be |
@JeffBezanson, thanks for pointing this out. I wasn't aware of the pitfall. On second thought, I realized the current behavior of Nevertheless, I think its' very handy to have a easy way of controlling over the level |
When
print
ing tuple, its contents are currently stringified byshow()
instead ofprint()
.I think it is preferable to use
print
for displaying its contents whenprint
ing tupleas
print
andshow
give different results for some types, as in the example above.The text was updated successfully, but these errors were encountered: