4 ms·
Direct link https://gist.github.com/Nurdok/4096182 https://gist.github.com/Nurdok/4096182 'oct' should also be added: >>> oct(45) '055' One caveat: P
by niggler 13y ago
Direct link https://gist.github.com/Nurdok/4096182 https://gist.github.com/Nurdok/4096182
'oct' should also be added:
>>> oct(45)
'055'
One caveat: Python doesn't assume the leading '0' indicates that the number is octal, so you must specify radix 8:
>>> int('055', 8)
45
- dandellion 13y agoWouldn't it be better to comment on the direct link, where the author is more likely to see it?
- niggler 13y agoValid point, comment submitted. I assumed the author submitted this to HN in the first place
- deleted 13y ago[deleted]
- Dylan16807 13y agoI would rather call that cause to celebrate than a caveat. The design of octal literals in C is ridiculous. In fact you almost can't write a program without using them inadvertently. :)