* On 2023 10 Jan 13:38 -0600, pa...@quillandmouse.com wrote:
> It may be argued that I shouldn't do the import this way. However, I
> prefer to have "curses." in front of things imported. It makes the link
> explicit, and serves to remind me of what's actually going on, when I
> revisit the code in five years.

I agree with your reasoning.  I never liked the "from foo import *"
syntax.  OTOH, it does have its use when wanting to import a subset of a
module.  For example, "from foo import bar" that would make the "bar"
name a part of the main namespace..

Then there is the "import fooBarBaz as fBB" syntax which is useful to
shorten long module names, as I understand it (the name after the "as"
can be any legal Python identifier).  There are some modules with
submodules that make the long name prefix onerous.

As I've poked around the Web over the years its clear that some like the
simplicity of "from foo import *".  I think doing that as an example is
a mistake as it hides the classes, methods, variables module prefix.
Just be aware that when you find an example that imports in this manner
that there is an implicit module name prefix but it isn't used since the
import command made the module's namespace a part of the program's main
namespace.

That's how I understand it, at least.

- Nate

-- 
"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."
Web: https://www.n0nb.us
Projects: https://github.com/N0NB
GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819

Attachment: signature.asc
Description: PGP signature

Reply via email to