I am out of trial and error again Lists
Cameron Simpson
cs at zip.com.au
Fri Oct 24 20:52:21 EDT 2014
On 24Oct2014 20:37, Seymore4Head <Seymore4Head at Hotmail.invalid> wrote:
>On Sat, 25 Oct 2014 01:20:53 +0100, MRAB <python at mrabarnett.plus.com>
>>One function you can use is repr:
>>
>>x = 1
>>y = "1"
>>print(repr(x))
>>print(repr(y))
>>
>>This will print:
>>
>>1
>>'1'
>>
>>OK, now it's clear that x is an int and y is a string.
>
>Yes
In particular, Python's interactive mode uses repr to print the result of any
expression that whose value was not None:
[/Users/cameron]fleet*> python
Python 2.7.8 (default, Oct 3 2014, 02:34:26)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x=1
>>> y='1'
>>> x
1
>>> y
'1'
>>>
so you get this for free in that mode.
Cheers,
Cameron Simpson <cs at zip.com.au>
If your new theorem can be stated with great simplicity, then there
will exist a pathological exception. - Adrian Mathesis
More information about the Python-list
mailing list