def extend ( self, xlist ):
        trait = getattr( self, 'trait', None )
        if trait is None:
            list.extend( self, xlist )

            return

        try:
            len_xlist = len( xlist )
        except:
            raise TypeError, "list.extend() argument must be iterable"

        if (trait.minlen <= (len( self ) + len_xlist) <= trait.maxlen):
            object   = self.object()
            name     = self.name
            validate = trait.item_trait.handler.validate
            try:
                if validate is not None:
                    xlist = [ validate( object, name, value )
                              for value in xlist ]

                list.extend( self, xlist )

                if (self.name_items is not None) and (len( xlist ) != 0):
                    self._send_trait_items_event( self.name_items,
                        TraitListEvent( len( self ) - len( xlist ), None,
                                        xlist ), trait.items_event() )

                return

            except TraitError, excp:
                excp.set_prefix( 'The elements of the' )
                raise excp

        self.len_error( len( self ) + len( xlist ) )
dataset/ETHPy150Open enthought/traits/traits/trait_handlers.py/TraitListObject.extend/original