[Pipet Devel] namespace

J.W. Bizzaro bizzaro at geoserve.net
Sun Feb 27 20:44:05 EST 2000

Brad Chapman wrote:
>     I don't think we need to worry about this too much because of the
> directory structure o' Loci. I think if anyone has another module in
> their PYTHONPATH called middle.library.modules.xml.frontTalkHandlers,
> then they *deserve* to have import problems. Plus, I don't see why
> anyone would really need or want to import loci classes other than us,
> and we can figure out if there will be problems.

The problem is, if we use...

    from middle.library.modules.xml.frontTalkHandlers import *

and you have a class named...


in the module, there is a good chance that using...

    from othermodule1 import *
    from othermodule2 import *
    from othermodule3 import *
    from othermodule4 import *

may also find a Print() class.

This is the problem with using an asterisk at the end of the import statement.

We could specify each class:

    from middle.library.modules.xml.frontTalkHandlers import Print

which I think is very helpful for keeping track of where classes are called
from, and even for finding unused classes.

The only other way is to use...

    import middle.library.modules.xml.frontTalkHandlers

The problem is, you are then required to put the module name at the beginning
of each class reference:

    print = middle.library.modules.xml.frontTalkHandlers.Print()

Eh.  Kind of long.

>     Also, I have been meaning to ask about how to work class and
> function names (some people really care a lot about this issue). I
> have been mostly using the lowerThenUpperCase type style for both
> classes, modules and functions (and variables). However, I know some
> people prefer lowerThenUpper for modules and classes and
> lots_of_underscores for functions. The style guide is kind o
> wishy-washy on this. Just curious if there were preferences...

>From my understanding of the style guide, and how I have been writing Python

    modules   --use--> alllowercasewithnospace.py
The exception to modules is if a module contains one class.  Then...
    modules   --use--> CapitalizedWords (same as classes)
    classes   --use--> CapitalizedWords
    methods   --use--> all_lowercase_with_underscore
    variables --use--> all_lowercase_with_underscore
or maybe
    variables --use--> mixedCase ???
(the style guide doesn't say, but I like alllowercase)
    constants --use--> ALL_CAPS_WITH_UNDERSCORE
(again, the guide doesn't say, but this is the C way)

I don't see anywhere that the mixedCase style is required.

                      |           J.W. Bizzaro           |
                      |                                  |
                      | http://bioinformatics.org/~jeff/ |
                      |                                  |
                      |        BIOINFORMATICS.ORG        |
                      |           The Open Lab           |
                      |                                  |
                      |    http://bioinformatics.org/    |

More information about the Pipet-Devel mailing list