Package gavo :: Package base :: Module unitconv :: Class UnitNode
[frames] | no frames]

Class UnitNode

source code

object --+    
         |    
     _Node --+
             |
            UnitNode

a terminal node containing a unit, possibly with a prefix

This is normally constructed through the fromToks constructor.

Check out the unit, prefix, and isUnknown attributes. The prefix can be turned to a factor using the PREFIXES dictionary. An empty prefix (factor 1) is represented by an empty string.

Instance Methods
 
__init__(self, unit, prefix='')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
getSI(self)
returns a pair of factor and basic unit.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods
 
fromToks(cls, s, p, toks) source code
Properties

Inherited from object: __class__

Method Details

__init__(self, unit, prefix='')
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

fromToks(cls, s, p, toks)
Class Method

source code 
Overrides: _Node.fromToks

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

getSI(self)

source code 

returns a pair of factor and basic unit.

Basic units are what's in the defining pairs in the PLAIN_UNITS dict.