unicodedata.name

Fredrik Lundh fredrik at pythonware.com
Wed Feb 1 12:06:33 EST 2006


Szabolcs Nagy wrote:

> the unicodedata manual sais:
> "
> name(  unichr[, default])
>     Returns the name assigned to the Unicode character unichr as a
> string. If no name is defined, default is returned, or, if not given,
> ValueError is raised.
> "
> what is the difference between "no name defined" and "not given"?

"no name is defined" refers to the unicode database, "not given"
refers to the default argument.  if you don't specify a default, and
the character don't have a known name, you get a ValueError.

> eg. '\n' why gives a ValueError?
>
> >>> unicodedata.name(u'\n')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ValueError: no such name

the Unicode standard doesn't specify names for control characters.

</F>






More information about the Python-list mailing list