Package nltk :: Module internals :: Class ElementWrapper
[hide private]
[frames] | no frames]

type ElementWrapper

source code

object --+
         |
        ElementWrapper

A wrapper around ElementTree Element objects whose main purpose is to provide nicer __repr__ and __str__ methods. In addition, any of the wrapped Element's methods that return other Element objects are overridden to wrap those values before returning them.

This makes Elements more convenient to work with in interactive sessions and doctests, at the expense of some efficiency.

Instance Methods [hide private]
 
__init__(self, etree)
Initialize a new Element wrapper for etree.
source code
 
unwrap(self)
Return the Element object wrapped by this wrapper.
source code
    String Representation
 
__repr__(self) source code
 
__str__(self)
Returns: the result of applying ElementTree.tostring() to the wrapped Element object.
source code
    Element interface Delegation (pass-through)
 
__getattr__(self, attrib) source code
 
__setattr__(self, attr, value) source code
 
__delattr__(self, attr) source code
 
__setitem__(self, index, element) source code
 
__delitem__(self, index) source code
 
__setslice__(self, start, stop, elements) source code
 
__delslice__(self, start, stop) source code
 
__len__(self) source code
    Element interface Delegation (wrap result)
 
__getitem__(self, index) source code
 
__getslice__(self, start, stop) source code
 
getchildren(self) source code
 
getiterator(self, tag=None) source code
 
makeelement(self, tag, attrib) source code
 
find(self, path) source code
 
findall(self, path) source code
Static Methods [hide private]
 
__new__(cls, etree)
Create and return a wrapper around a given Element object.
source code
Method Details [hide private]

__new__(cls, etree)
Static Method

source code 

Create and return a wrapper around a given Element object. If etree is an ElementWrapper, then etree is returned as-is.

Overrides: object.__new__

__init__(self, etree)
(Constructor)

source code 

Initialize a new Element wrapper for etree. If etree is a string, then it will be converted to an Element object using ElementTree.fromstring() first.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
Returns:
the result of applying ElementTree.tostring() to the wrapped Element object.
Overrides: object.__str__

__setattr__(self, attr, value)

source code 
Overrides: object.__setattr__
(inherited documentation)

__delattr__(self, attr)

source code 
Overrides: object.__delattr__
(inherited documentation)