list Integer indexing dies??

Lonnie Princehouse finite.automaton at gmail.com
Thu Dec 23 13:08:21 EST 2004


> ;-) gotcha. But shouldn't this be valid too??
> >>> 123232[0]

No, it shouldn't be valid.  It makes the implicit assumption that you
want the base 10 digit, which isn't really a good assumption to make in
the world of computers.  Programmers are just as likely to want
hexadecimal, and arguments could be made for octal or binary too.
Basically, there's no intuitive meaning for trying to slice an integer.

Also, it seems like it would be very rare that anybody would want to do
this.  Most of those cases fall into one of two categories- (1) trying
to display digits of a number in a human readable way, and (2) trying
to do some kind of math.

(1) is better handled by explicitly converting it to a string first,
and 
(2) is likely better handled using logarithms.




More information about the Python-list mailing list