[Python-ideas] print in the interactive interpreter? plus shell API idea

Roman Susi rnd at onego.ru
Sun Jul 6 17:49:59 CEST 2008


Oleg Broytmann wrote:
> On Sun, Jul 06, 2008 at 12:22:17PM +1200, Greg Ewing wrote:
>> Roman Susi wrote:
>>
>>> Before it were simple to print something with print. Now extra ( and )
>>> are needed and also extra caution.
>> How often does one really need to use print in the interactive
>> shell, given than you can just type an expression and get
>> the repr of the result?
> 
>    It is is not always repr():
> 
> $  python
> Python 2.5 (release25-maint, Dec  9 2006, 14:35:53) 
> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> print '' or None
> None
>>>> '' or None
>>>> print ['тест']
> ['\xd4\xc5\xd3\xd4']
>>>> ['тест']
> ['тест']

Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Readline loaded.
History loaded.
>>> ['тест']
['\xd1\x82\xd0\xb5\xd1\x81\xd1\x82']
>>> print ['тест']
['\xd1\x82\xd0\xb5\xd1\x81\xd1\x82']

>    Note the difference.

Can't see any difference in the latter example (matter of encodings, I
guess), however, None is treated specially, it is true.

At any rate, repr or not, its more typing to get the "nicer" result.
My point is that the shell could be more sophisticated.

> Oleg.

-Roman



More information about the Python-ideas mailing list