Repository navigation
Incorrect description about scope related with inheritance #73196
Description
Activity
The current description is "The name BaseClassName must be defined in a scope containing the derived class definition", which did not conform to the actual situation ,e.g. the base class object is not in the same scope as the derived class.
The associated link is https://docs.python.org/3.6/tutorial/classes.html#inheritance
brendan-donegan commented
on Dec 19, 2016 brendan-doneganmannequinMannequinMore actionsHi. Can you please provide a small code snippet illustrating where this diverges from the actual behaviour?
Code:
class A(object):
pass'object' is not in the same scope as 'A'
It is part of the global scope, which contains all other scopes. (I'm not 100% sure I'm comfortable with that language, but it doesn't seem obviously wrong.)
The previous description about scope classify it into 3 types explicitly, which means the scope containing the current module's global names is not same as the scope containing built-in names.
If i was wrong about this issue, please tell me.
brendan-donegan commented
on Dec 20, 2016 brendan-doneganmannequinMannequinMore actionsIMO there's no actual bug in Python. Perhaps documentation can be clarified
in a short simple way. I would reiterate the point that restating facts of
the language all over the documentation is not a great idea, but maybe here
the benefits outweigh the drawbacks.Anyway I think the bug is clear now (it's a docs issue if anything) so I'd
leave it open until someone offers a patch or a strong argument why it
shouldn't be clarified.On Tue, 20 Dec 2016 at 09:18 woo yoo <report@bugs.python.org> wrote:
woo yoo added the comment:
If i was wrong about this issue, please tell me.
----------
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue29010\>
I agree with you
Would it make it clearer if we said "BaseClassName must be defined in a namespace accessible from the scope containing the dervied class definition" ?
brendan-donegan commented
on Dec 20, 2016 brendan-doneganmannequinMannequinMore actionsWorth putting them side by side I think:
"The name BaseClassName must be defined in a scope containing the derived class definition"
vs.
"BaseClassName must be defined in a namespace accessible from the scope containing the derived class definition"
As for me, i prefer the new description, which is clear and easy to understand.
- added3.9 (EOL)end of lifeend of life3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes
on Nov 19, 2021 - added a commit that references this issue
on Oct 7, 2022 - added a commit that references this issue
on Oct 8, 2022 - added a commit that references this issue
on Oct 11, 2022
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: