Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36809

Re: PyWart: Module access syntax

References <8e9b2b0e-1c34-46cc-80c6-57fbb5fd756c@googlegroups.com> <50f03799$0$30003$c3e8da3$5496439d@news.astraweb.com> <9b64719e-1e06-47fa-a7e6-692a3dd360d0@googlegroups.com> <50f1066f$0$30003$c3e8da3$5496439d@news.astraweb.com> <af1ad595-4ee6-4b9f-86fb-845c025fb417@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-01-14 11:51 -0700
Subject Re: PyWart: Module access syntax
Newsgroups comp.lang.python
Message-ID <mailman.512.1358189552.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Jan 13, 2013 at 10:22 PM, Rick Johnson
<rantingrickjohnson@gmail.com> wrote:
> You are missing the point of this syntax. The colon is to access MODULE NAMESPACE. The dot is to access MODULE MEMBERS. A module CAN BE another module's MEMBER.
>
> You are also unable to grasp this simple logical fact: Once you arrive at /any/ MODULE and you start accessing MEMBERS, you will *_ALWAYS_* find members from that point downwards.

If you want us to understand the syntax, then you need to define
precisely what you mean by these terms.  In what situation does a
module have a dotted/coloned path without being a member of another
module?  Any time you import a.b, the import mechanism finds and loads
module b and adds it *as a member* to module a.  It follows that a
module accessible by a module path is *always* a member of another
module.  By the above rule, then it would seem that the dot would
always be used, and the colon never.

I think the distinction you are trying to make here is based upon the
submodule's actual source location on the disk.  If you have a package
folder A which contains a file B.py, then you would access that as
A:B, correct?  If on the other hand you have a module A.py or package
A/__init__.py that loads a module from some other location and then
stores it in the A module with the name "B", then that would be "A.B",
correct?

If I have that right, then the problem with this is that it breaks the
virtualization and encapsulation of Python's package structure.  When
I import os.path, I don't have to know or care how the submodule
relationship is implemented, whether it's a simple module in a package
or something more complicated.  All I need to know is that path is a
submodule of os.  What you're asking for is that I have to type either
"os.path" or "os:path" depending on an implementation detail of the
module structure, and if that implementation detail ever changes, then
my code breaks.

> Because modules and objects are not the same and someone who is reading the source code NEEDS to know which "path members" are /modules/ and which "path members" are /objects/.  And he needs to know that very important information WITHOUT opening source files to find out.

Why does anybody reading the source code need to know this?  We're
talking about simple namespaces here.  Nobody reading the source needs
to care whether those namespaces are implemented as modules or some
other type of object.  The only substantive difference between the two
is whether you can expect to be able to import them directly.  If you
need to know that, read the documentation.  If they're documented as
modules, then you can import them.  Otherwise, make no such
assumption, because even if it works now, that could change later.

If we're *not* talking about simple namespaces, then it should be very
obvious that they are not modules based upon the fact that the code
uses them in ways that modules are not normally used for.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-10 22:01 -0800
  Re: PyWart: Module access syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-11 16:02 +0000
    Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 20:34 -0800
      Re: PyWart: Module access syntax Chris Angelico <rosuav@gmail.com> - 2013-01-12 15:40 +1100
        Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 21:46 -0800
          Re: PyWart: Module access syntax Chris Angelico <rosuav@gmail.com> - 2013-01-12 16:59 +1100
          Re: PyWart: Module access syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-12 06:53 +0000
        Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 21:46 -0800
        Re: PyWart: Module access syntax 88888 Dihedral <dihedral88888@googlemail.com> - 2013-01-12 16:02 -0800
        Re: PyWart: Module access syntax 88888 Dihedral <dihedral88888@googlemail.com> - 2013-01-12 16:02 -0800
      Re: PyWart: Module access syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-12 06:45 +0000
        Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-13 21:22 -0800
          Re: PyWart: Module access syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-14 17:34 +0000
            Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 23:07 -0800
          Re: PyWart: Module access syntax Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-14 11:51 -0700
            Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 23:49 -0800
              Re: PyWart: Module access syntax Chris Angelico <rosuav@gmail.com> - 2013-01-15 19:08 +1100
            Re: PyWart: Module access syntax Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-14 23:49 -0800
          Re: PyWart: Module access syntax Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-14 12:04 -0700
          Re: PyWart: Module access syntax "D'Arcy J.M. Cain" <darcy@druid.net> - 2013-01-14 14:35 -0500
          Re: PyWart: Module access syntax Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-14 13:38 -0700
      Re: PyWart: Module access syntax Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-11 23:55 -0700
      Re: PyWart: Module access syntax alex23 <wuwei23@gmail.com> - 2013-01-11 23:36 -0800
  Re: PyWart: Module access syntax Nicholas Cole <nicholas.cole@gmail.com> - 2013-01-12 12:16 +0000

csiph-web