[SciPy-dev] Namespaces in documentation

John Hunter jdh2358@gmail....
Tue Jun 3 11:39:15 CDT 2008


On Tue, Jun 3, 2008 at 9:11 AM, Joe Harrington <jh@physics.ucf.edu> wrote:

> Is there any other place in Python (or indeed in computer science)
> where a package advocates referring to itself by something other than

>From Bjarne Stroustrup "Programming Language C++, 3rd edition" Section 8,2
"Namespaces"::

  If users give their namespaces short names, the names of different
  namespaces will clash:

    namespace A { //short name, will clash (eventually)

  However, long namespaces can be impractical in real code:

    namespace American_Telephone_and_Telegraph { //too long

  This dilemma can be resolved by providing a short alias for a longer
  namespace name

    //use namespace alias to shorten names:
    namespace ATT = American_Telephone_and_Telegraph;
    ATT:String s3 = "Grieg";

  Namespace aliases allow a user to refer to "the library" and have a
  single declaration defining what library that really is.  For example:

  namespace Lib = Foundation_library_v2r11;


Well said.  Because they are so handy, most languages provide
facilities for aliases::

    python  : import something as somethingelse
    C++     : namespace new_name = current_name;
    Bash    : alias ls='ls -F'
    C       : # DEFINE
    C#      : using colAlias = System.Collections;
    Texinfo : @alias new=existing'
    Perl    : use perl Alias

And we needn't look too far beyond our own doors, since there is broad
agreement here on the usefulness of namespace aliases.

JDH


More information about the Scipy-dev mailing list