So here is what I am typing
>>> list = [1,2,3]
>>> list.__doc__
"list() -> new empty list\nlist(iterable) -> new list initialized from iterable's items"
The problem being that it literally prints "\\n" instead of printing a new line, making more complicated doc strings almost impossible to read.
The same thing happens with all of the other built-in classes I have tried.
The version information I get from python when I open it is: Python 2.7.5 (default, Jul 16 2013, 14:23:29) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
That is because the list.__doc__
is a string.
When you just type list.__doc__
you will get the contents like this :
>>> list.__doc__ "list() -> new empty list\nlist(iterable) -> new list initialized from iterable's items"
However if you type print list.__doc__
>>> print list.__doc__ list() -> new empty list list(iterable) -> new list initialized from iterable's items
So the print function properly formats the string to include the linebreak.
Hope that helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.