[Tutor] display-related questions

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Sun, 9 Jul 2000 00:19:10 -0700 (PDT)


On Sun, 9 Jul 2000, Sean Dwyer wrote:

> 1. I'm writing an innocuous command-line fibonacci numbers program. So
> that users can input almost any size number to determine the length of
> the sequence, I've had to use long integers.
> 
> Unfortunately this also output every number with a long integer
> indicator (eg 987L). Is it possible to avoid this in output, and how?

Richard has already posted a way of removing the 'L' at the end of the
output string.  However, you should be aware that the next version of
Python (2.0) coming up will not append the 'L' on long ints, so be
prepared to switch back... *grin*  Here's a quote from the new-features
commentary:

"The subtlest long integer change of all is that the str() of a long
integer no longer has a trailing 'L' character, though repr() still
includes it. The 'L' annoyed many people who wanted to print long integers
that looked just like regular integers, since they had to go out of their
way to chop off the character. This is no longer a problem in 2.0, but
code which assumes the 'L' is there, and does str(longval)[:-1] will now
lose the final digit."

This comes from:

  http://starship.python.net/crew/amk/python/writing/new-python/