Re: Calling global functions from a class?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: Calling global functions from a class?

    Robert Dailey wrote:
    I have the following python script:
    >
    def __normalizePath ( path ):
    return osp.abspath( osp.normpath( path ) )
    >
    class AbsolutePath:
    def __init__( self, root="" ):
    _root = __normalizePath ( root )
    >
    >
    When I create an AbsolutePath object, I get the following error:
    >
    NameError: global name '_AbsolutePath_ _normalizePath' is not defined
    >
    Is there a reason for this?
    the "__" prefix (double underscores) is reserved for private attributes
    and methods in a class. it does not work for module-level names.
    How can I make this work?
    rename the global function.

    </F>

Working...