This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Availability of parsers in etree initializer
Type: behavior Stage: resolved
Components: XML Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eli.bendersky, ned.deily, nilanjan roy, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-08-22 10:41 by nilanjan roy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8857 closed python-dev, 2018-08-22 12:11
PR 9012 closed python-dev, 2018-08-31 06:45
Messages (6)
msg323872 - (view) Author: nilanjan roy (nilanjan roy) Date: 2018-08-22 10:41
As xml package make the availability of separate global name-space by *__all__* so considerably *etree* should have included of all the parser files in its initialize(i.e. in *__init__.py*). 

So if any script consider as "from xml import *" then *etree* should have accessibility on all of it's parser files i.e. etree should access like *etree.ElementTree* which is not working as expected currently. Currently it's enforced to use as normal behavior as "import xml.etree.ElementTree"
msg324018 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2018-08-24 21:08
The normal way to use ElementTree is to import the ElementTree module from the xml.etree package. Why do you think that needs to change? And why do you want to enforce an import of all modules before you even know which of them the users actually wants?
msg324499 - (view) Author: nilanjan roy (nilanjan roy) Date: 2018-09-03 07:10
@scoder: *xml* package organization have little confusion 

1. Current xml have exposed all the sub-packages from *__all__* scope from the initializer - so there are possibilities to write code from script 
a. *import xml as x* or *import xml.somepackage as x* => which is also possible even if I do not declare the sub-packages from *__all__* scope
of an initializer
b. as all the subpackages are available in xml initialzer scope- so this is allowed to developer to write *from xml import ** - but this flexibility will not work(which is contradictory)  as each of sub-package initializer doesn't have any inclusion(which i have included in PR) 

Regards,
msg324501 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-03 07:30
I concur with Stefan. Not all users of ElementTree need to import ElementInclude, ElementPath and deprecated cElementTree. If you need ElementInclude or ElementPath, it is better to specify this explicitly. The star import is not recommended in general case (you even can't use it in a local scope in Python 3). The valid use of it is with modules that define a lot of names and are specially designed for this (like tkinter or turtle) and in an interactive session.
msg324559 - (view) Author: nilanjan roy (nilanjan roy) Date: 2018-09-04 06:50
@serhiy.storchaka: 

If I concur with your comment then probably declaration of *__all__** over xml initializer(__init__) is little contradictory - because whenever we declare __all__ to enable global-scope means API provides the flexibility to use * during package import. Now this is totally depends on developer how the script need to optimize/simulate during development. Yes agree * should not be used due to high reference of memory usage. But as far __init__.py of xml and python convention this should not be explicitly restricted
msg338158 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-03-18 03:24
Thanks for the suggestion but, since there has been no agreement that this change is desirable, I am going to close the issue along with the submitted PRs.
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78642
2019-03-18 03:24:49ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg338158

resolution: not a bug
stage: patch review -> resolved
2018-09-04 06:50:45nilanjan roysetmessages: + msg324559
2018-09-03 07:30:07serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg324501
2018-09-03 07:10:11nilanjan roysetmessages: + msg324499
2018-08-31 06:45:34python-devsetpull_requests: + pull_request8482
2018-08-24 21:08:46scodersetmessages: + msg324018
2018-08-22 13:09:37ronaldoussorensetnosy: + scoder, eli.bendersky
2018-08-22 12:11:16python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8330
2018-08-22 10:41:28nilanjan roycreate