Integers have docstring for int()

A

Andrew Durdin

I accidentally discovered that all the basic types in Python have
docstrings that describe the functions to create them. For integers,
you get:
'int(x[, base]) -> integer\n\nConvert a string or number to an integer, if possi
ble. A floating point\nargument will be truncated towards zero (this does not i
nclude a string\nrepresentation of a floating point number!) When converting a
string, use\nthe optional base. It is an error to supply a base when converting
a\nnon-string. If the argument is outside the integer range a long object\nwill
be returned instead.'

Similarly, (1.0).__doc__ gives the docstring for float(), "".__doc__
gives it for str(), [].__doc__ gives it for list(), and {}.__doc__
gives it for dict().

This seems a little unexpected to me; is there any particular reason
for this behaviour?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top