@classmethod
def from_name(cls, name, data=0):
    """
        Construct a :class:`Block` instance from a *name*, as returned by the
        :attr:`name` property. This may be used to construct blocks in a more
        "friendly" way within code. For example::

            >>> from picraft import *
            >>> Block.from_name('stone')
            <Block "stone" id=1 data=0>
            >>> Block.from_name('wool', data=2)
            <Block "wool" id=35 data=2>

        The optional *data* parameter can be used to specify the data component
        of the new :class:`Block` instance; it defaults to 0. Note that calling
        the default constructor with a string that doesn't start with "#" is
        equivalent to calling this method::

            >>> Block('stone')
            <Block "stone" id=1 data=0>
        """
    if isinstance(name, bytes):
        name = name.decode('utf-8')
    try:
        id_ = cls._BLOCKS_BY_NAME[name]
    except KeyError:
        raise ValueError('unknown name %s' % name)
    return cls(id_, data)
