under naming

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Bear

    #1

    under naming

    I must have missed reading something important about naming conventions.

    I have found that if I have a python module where I have an identifier named
    with a beginning underscore that I cannot use from module import * to make
    that name available in another module.

    for example,
    module A

    _myvar = 'a local var'

    module B
    from A import *

    _myvar -- is not available.

    Is this in a pep somewhere ?

    --
    David Bear
    -- let me buy your intellectual property, I want to own your thoughts --
  • Robert Kern

    #2
    Re: under naming

    David Bear wrote:
    I must have missed reading something important about naming conventions.
    >
    I have found that if I have a python module where I have an identifier named
    with a beginning underscore that I cannot use from module import * to make
    that name available in another module.
    >
    for example,
    module A
    >
    _myvar = 'a local var'
    >
    module B
    from A import *
    >
    _myvar -- is not available.
    >
    Is this in a pep somewhere ?
    No; this has been a feature since before the time of PEPs. However, it is
    documented here:



    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco

    Comment

    • John Machin

      #3
      Re: under naming


      David Bear wrote:
      I must have missed reading something important about naming conventions.
      >
      I have found that if I have a python module where I have an identifier named
      with a beginning underscore that I cannot use from module import * to make
      that name available in another module.
      >
      for example,
      module A
      >
      _myvar = 'a local var'
      >
      module B
      from A import *
      >
      _myvar -- is not available.
      >
      Is this in a pep somewhere ?
      >
      The official home of the Python Programming Language


      Comment

      Working...