def set(self, value):
        """Assign the native and Unicode value.

        :returns: True if adaptation of *value* was successful.

        Attempts to adapt the given value and assigns this element's
        :attr:`~flatland.Element.value` and :attr:`u`
        attributes in tandem.

        If adaptation succeeds, ``.value`` will contain the
        :meth:`adapted<adapt>` native Python value and ``.u`` will contain a
        Unicode :meth:`serialized<serialize>` version of it.  A native value
        of ``None`` will be represented as ``u''`` in ``.u``.

        If adaptation fails, ``.value`` will be ``None`` and ``.u`` will
        contain ``unicode(value)`` or ``u''`` for none.

        """
        try:
            # adapt and normalize the value, if possible
            value = self.value = self.adapt(value)
        except AdaptationError:
            self.value = None
            if value is None:
                self.u = u''
            elif isinstance(value, unicode):
                self.u = value
            else:
                try:
                    self.u = unicode(value)
                except __HOLE__:
                    self.u = unicode(value, errors='replace')
            return False

        # stringify it, possibly storing what we received verbatim or a
        # normalized version of it.
        if value is None:
            self.u = u''
        else:
            self.u = self.serialize(value)
        return True
dataset/ETHPy150Open jek/flatland/flatland/schema/scalars.py/Scalar.set