msg183458 - (view) |
Author: Phil Elson (pelson) * |
Date: 2013-03-04 14:36 |
The example at http://docs.python.org/3.4/howto/descriptor.html#properties does not run due to the old style "raise AttributeError, message" form. This patch fixes the problem, and also goes through the docs to remove explicit sub-classing from "object". The only remaining instances of this now are: $> grep -r -E "class .*\(object\)\:" Doc/* Doc/howto/pyporting.rst: class UnicodeMixin(object): Doc/reference/compound_stmts.rst: class Foo(object): Doc/tools/sphinxext/pyspecific.py:class PyDecoratorMixin(object): Doc/whatsnew/2.6.rst: class C(object): Doc/whatsnew/2.2.rst: class C(object): Doc/whatsnew/2.2.rst: class C(object): Doc/whatsnew/2.2.rst: class C(object): Doc/whatsnew/2.2.rst: class C(object): Doc/whatsnew/2.2.rst: >>> class C(object): Which are all (minus tools/sphinxext/pyspecific) referring to python2 in some context. I'm not bound to fixing the explicit object subclassing, so if it is better off not being here, that's fine. Cheers, |
|
|
msg183796 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2013-03-09 04:43 |
The respective howto and examples authors should give their OK for deleting '(object)' in case they are trying to keep one text compatible across 2 and 3. I added the other two to the nosy list. Doc/howto/descriptor.rst -- Raymond H. Doc/howto/sorting.rst -- Raymond H. Doc/howto/logging-cookbook.rst -- Vinay S. Doc/library/unittest.mock-examples.rst -- Michael F. Since raise AttributeError(message) works in 2.x, I think that should definitely be changed in descriptor.rst. I also think the regular docs can be changed without further ado. Doc/library/contextlib.rst Doc/library/functions.rst Phil, your name does not have a Contributor Agreement *. If it should, say so and lets figure out why not. Otherwise, please fill out one at http://www.python.org/psf/contrib/ Choose paper mail, paper scan and email, or javascript e-form. |
|
|
msg183804 - (view) |
Author: Vinay Sajip (vinay.sajip) *  |
Date: 2013-03-09 07:34 |
I'm OK with changing the logging cookbook to remove explicit subclassing from "object" in the examples. |
|
|
msg183864 - (view) |
Author: Ned Batchelder (nedbat) *  |
Date: 2013-03-10 03:09 |
Why is it important to remove subclassing object? Isn't it still good form to mention object as a base class. |
|
|
msg183867 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2013-03-10 04:37 |
> Why is it important to remove subclassing object? It's not /important/, but those are just leftovers from 2.x, and there's no reason to keep them around. > Isn't it still good form to mention object as a base class. I don't think so (or at least I've never seen anyone suggesting to keep or add "object" explicitly). The patch LGTM, so unless there's a valid reason to keep the "object" around I'll commit it soon. |
|
|
msg183870 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2013-03-10 06:46 |
[Ned] > Isn't it still good form to mention object as a base class. I don't think so. The classes look much cleaner without it. +1 from for removing (object) from most examples (except for the descriptor howto). [Terry] > The respective howto and examples authors should give their > OK for deleting '(object)' in case they are trying to keep > one text compatible across 2 and 3. I added the other two > to the nosy list. Thanks Terry. Yes, I would like to keep (object) in the text of the descriptor how-to. As you said, it keeps the text compatible. But also, the explicit inheritance from (object) is an aid to clarity in a document that needs to highlight that attribute access occurs in two forms, object.__getattribute__ and type.__getattribute__. |
|
|
msg183884 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-03-10 16:37 |
New changeset 513c4aaf70d7 by Raymond Hettinger in branch '2.7': Issue #17351: Modernize the pure Python property() example. http://hg.python.org/cpython/rev/513c4aaf70d7 |
|
|
msg183885 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-03-10 16:42 |
New changeset bb7e01b5d362 by Raymond Hettinger in branch '3.3': Issue #17351: Modernize the pure Python property() example. http://hg.python.org/cpython/rev/bb7e01b5d362 |
|
|
msg183933 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2013-03-11 05:20 |
My rationale for supporting removal is this: People beginning with Py3, which is most beginners in the next decade, seeing (object), might think it necessary in certain cases or that it does something. The descriptor how-to is a) advanced and b) can have a note if needed. People who know Py2 might get a wrong idea either way, but should read some 2 to 3 guide and then will know. If a choice be needed, I would rather cater to future Python learners. Anyway, we only need Michael's word to know for sure which to patch, or can go ahead without touching mock-examples. |
|
|
msg183940 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-03-11 07:43 |
New changeset 4f745f7d6fca by Ezio Melotti in branch '3.2': #17351: remove "object" inheritance from docs. Patch by Phil Elson. http://hg.python.org/cpython/rev/4f745f7d6fca New changeset 8b1d3fa3b389 by Ezio Melotti in branch '3.3': #17351: merge with 3.2. http://hg.python.org/cpython/rev/8b1d3fa3b389 New changeset b10a9d4f08eb by Ezio Melotti in branch 'default': #17351: merge with 3.3. http://hg.python.org/cpython/rev/b10a9d4f08eb |
|
|
msg183941 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2013-03-11 07:45 |
Fixed, thanks for the patch! |
|
|
msg183945 - (view) |
Author: Michael Foord (michael.foord) *  |
Date: 2013-03-11 10:09 |
If the consensus is that Python documentation should not include explicit object inheritance then fine to update mock docs accordingly. The backport docs will still use it as they are for Python 2 as well. |
|
|