def __init__(self, trytes, pad=None):<EOL>
super(TryteString, self).__init__()<EOL>if isinstance(trytes, (int, float)):<EOL><INDENT>raise with_context(<EOL>exc=TypeError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>type=type(trytes).__name__,<EOL>cls=type(self).__name__,<EOL>),<EOL>),<EOL>context={<EOL>'<STR_LIT>': trytes,<EOL>},<EOL>)<EOL><DEDENT>if isinstance(trytes, TryteString):<EOL><INDENT>incoming_type = type(trytes)<EOL>if (<EOL>(incoming_type is TryteString) or<EOL>issubclass(incoming_type, type(self))<EOL>):<EOL><INDENT>trytes = bytearray(trytes._trytes)<EOL><DEDENT>else:<EOL><INDENT>raise with_context(<EOL>exc=TypeError(<EOL>'<STR_LIT>'.format(<EOL>type=type(trytes).__name__,<EOL>cls=type(self).__name__,<EOL>),<EOL>),<EOL>context={<EOL>'<STR_LIT>': trytes,<EOL>},<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(trytes, text_type):<EOL><INDENT>trytes = encode(trytes, '<STR_LIT:ascii>')<EOL><DEDENT>if not isinstance(trytes, bytearray):<EOL><INDENT>trytes = bytearray(trytes)<EOL><DEDENT>for i, ordinal in enumerate(trytes):<EOL><INDENT>if ordinal not in AsciiTrytesCodec.index:<EOL><INDENT>raise with_context(<EOL>exc=ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>char=chr(ordinal),<EOL>i=i,<EOL>),<EOL>),<EOL>context={<EOL>'<STR_LIT>': trytes,<EOL>},<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if pad:<EOL><INDENT>trytes += b'<STR_LIT>' * max(<NUM_LIT:0>, pad - len(trytes))<EOL><DEDENT>self._trytes = trytes<EOL>
:param trytes:
    Byte string or bytearray.

:param pad:
    Ensure at least this many trytes.

    If there are too few, null trytes will be appended to the
    TryteString.

    .. note::
        If the TryteString is too long, it will *not* be
        truncated!