Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace
The fact of explicit dependency noting is why I suggested something that explicitly defines multiple imports in one line On Sat, Apr 28, 2018 at 9:28 PM Greg Ewingwrote: > Nick Coghlan wrote: > > I find the imports at the top of the file to be a nice > > catalog of external dependencies. > > Not only is it useful for human readers, it's also useful > for packaging tools such as py2exe that need to know which > modules are being used. > > I experimented once with auto-importing in PyGUI, but in > the end I dropped it, partly because of this consideration. > > There were other problems with it as well. I don't recall > all the details, but I think one issue is that any errors > resulting from an import triggered by an attribute access > get masked and turned into an AttributeError, making them > very confusing to diagnose. > > Also, importing requires acquisition of the import lock, > which could cause problems in a multithreaded environment > if it happens at unpredictable times. > > For these reasons I'm inclined to regard auto-importing > as an anti-pattern -- it seems like it should be a good > idea, but it leads to more problems than it solves. > > -- > Greg > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Thanks, Julian DeMille CEO, demilleTech, LLC This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace
That's the kind of thing I'm looking for. I've dealt with some library authors who were highly against importing the root allowing me to access submodules with hierarchy. On Thu, Apr 26, 2018 at 9:51 AM Nick Coghlan <ncogh...@gmail.com> wrote: > On 26 April 2018 at 23:37, Paul Moore <p.f.mo...@gmail.com> wrote: > > On 26 April 2018 at 14:29, Julian DeMille via Python-ideas > > <python-ideas@python.org> wrote: > >> I personally would like a feature where instead of doing `from ... > import > >> ...` (which imports the specified items into the current namespace), one > >> could use something along the lines of `import .{ , , > ... > >> }` such that the imported modules/attributes could be accessed as > >> `.`, etc. > > > > What are the benefits of this over a simple "import "? > > Forcing submodule imports would be the main thing, as at the moment, > you have to choose between repeating the base name multiple times > (once per submodule) or losing the hierarchical namespace. > > So where: > > from pkg import mod1, mod2, mod3 > > bind "mod1", "mod2", and "mod3" in the current namespace, you might > instead write: > > from pkg import .mod1, .mod2, .mod3 > > to only bind "pkg" locally, but still make sure "pkg.mod1", "pkg.mod2" > and "pkg.mod3" all resolve at import time. > > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > -- Thanks, Julian DeMille CEO, demilleTech, LLC This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
Re: [Python-ideas] Allow multiple imports from a package while preserving its namespace
Some library authors get pretty pissy about implicit imports at the root On Thu, Apr 26, 2018, 09:37 Paul Moore <p.f.mo...@gmail.com> wrote: > On 26 April 2018 at 14:29, Julian DeMille via Python-ideas > <python-ideas@python.org> wrote: > > I personally would like a feature where instead of doing `from ... import > > ...` (which imports the specified items into the current namespace), one > > could use something along the lines of `import .{ , , > ... > > }` such that the imported modules/attributes could be accessed as > > `.`, etc. > > What are the benefits of this over a simple "import "? I get that > it will mean that *only* the names listed will be accessible as > ., but I don't see why that's important (and specifically > why it's important enough to warrant dedicated syntax). Hiding names > in a namespace isn't typically something that Python provides language > support for. > > Paul > -- Thanks, Julian DeMille CEO, demilleTech, LLC This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Allow multiple imports from a package while preserving its namespace
I personally would like a feature where instead of doing `from ... import ...` (which imports the specified items into the current namespace), one could use something along the lines of `import .{ , , ... }` such that the imported modules/attributes could be accessed as `.`, etc. -- Thanks, Julian DeMille CEO, demilleTech, LLC This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/