New submission from Robert Smallshire:

The documentation for the int(x) constructor explains that if possible, it 
delegates to x.__int__().   The documentation does not explain that there is a 
fallback to x.__trunc__() if x.__int__() is not available.

The only mention of __trunc__ in the Python documentation is in the entry for 
math.trunc; the documentation for the numbers module does not describe the 
underlying special methods.

Given that all Real numbers are required to implement __trunc__ but only 
Integral subclasses are required to implement __int__ this could be important 
to implementers of other Real types, although in practice I imagine that most 
Real types will implement __int__ as float does.

----------
assignee: docs@python
components: Documentation
messages: 262941
nosy: Robert Smallshire2, docs@python
priority: normal
severity: normal
status: open
title: Documentation for int constructor mentions __int__ but not __trunc__
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26701>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to