I'm opposed to changing int so that int('123_456') ignores the _ as that will change the behavior of existing code and could break apps.<div><br></div><div>Alternatively, if you want to change int how about int('123_456', separator='_') ignores the _. That would also admit int('123,456', separator=',')<div>
<div><br clear="all">--- Bruce<div><div><b><i><br></i></b></div></div>
<br><br><div class="gmail_quote">On Fri, May 6, 2011 at 4:41 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 06/05/2011 23:51, Cameron Simpson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 06May2011 15:40, Ethan Furman<<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>> wrote:<br>
| Bruce Leban wrote:<br>
|>Is _ just ignored in numbers or are there more complex rules?<br>
|><br>
|> * 1_2345_6789 (can I use groups of other sizes instead?)<br>
|> * 1_2_3_4_5 (ditto)<br>
|> * 1_234_6789 (do all the groups need to be the same size?)<br>
|> * 1_ (must the _ only be in between 2 digits?)<br>
|> * 1__234 (what about multiple _s?)<br>
|> * 9.876_543_210 (can it be used to the right of the decimal point?)<br>
|> * 0xFEFF_0042 (can it be used in hex, octal or binary numbers?)<br>
|> * int('123_456') (do other functions accept this syntax too?)<br>
|<br>
| I would say it's ignored. Have the rule be something like<br>
| number_string.replace('_','').<br>
|<br>
| The only wrinkle is that currently '_1' is usable name, and that<br>
| should probably be disallowed if the above change took place.<br>
|<br>
| I'm +1 on the idea.<br>
<br>
Personally I'm be for ignoring the _ also, save that I would forbid it<br>
at the start or end, so no _1 or 1_.<br>
<br>
And I would permit it in hex code etc.<br>
<br>
I'm +0.5, myself.<br>
<br>
</blockquote></div>
As far as I remember, Ada also permits it, but has the rule that it can<br>
occur only between digits. If we follow that, then:<br>
<br>
1_2345_6789 => Yes<br>
1_2_3_4_5 => Yes<br>
1_234_6789 => Yes<br>
1_ => No<br>
_1 => No<br>
1__234 => No<br>
9.876_543_210 => Yes<br>
9._876_543_210 => No<br>
9_.876_543_210 => No<br>
0xFEFF_0042 => Yes<br>
int('123_456') => Yes<div><div></div><div class="h5"><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br></div></div></div>