String

class datastructuretools.String

String.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_datastructuretools { graph [label=datastructuretools]; "abjad.tools.datastructuretools.String.String" [color=black, fontcolor=white, group=1, label=<<B>String</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=1, group=0, label=object, shape=box]; "builtins.str" [color=1, group=0, label=str, shape=box]; "builtins.object" -> "builtins.str"; } "builtins.str" -> "abjad.tools.datastructuretools.String.String"; }

Bases

  • builtins.str
  • builtins.object

Attribute summary

capitalize(() -> str) Return a capitalized version of S, i.e.
capitalize_start() Capitalizes start of string.
casefold(() -> str) Return a version of S suitable for caseless comparisons.
center((width[, fillchar]) -> str) Return S centered in a string of length width.
count((sub[, start[, end]]) -> int) Return the number of non-overlapping occurrences of substring sub in string S[start:end].
delimit_words() Delimits words in string.
encode((encoding=[, errors]) Encode S using the codec registered for encoding.
endswith((suffix[, start[, end]]) -> bool) Return True if S ends with the specified suffix, False otherwise.
expandtabs((tabsize=8) -> str) Return a copy of S where all tab characters are expanded using spaces.
find((sub[, start[, end]]) -> int) Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].
format((*args, **kwargs) -> str) Return a formatted version of S, using substitutions from args and kwargs.
format_map((mapping) -> str) Return a formatted version of S, using substitutions from mapping.
index((sub[, start[, end]]) -> int) Like S.find() but raise ValueError when the substring is not found.
is_dash_case() Is true when string is hyphen-delimited lowercase.
is_dash_case_file_name() Is true when string is hyphen-delimited lowercase file name with extension.
is_lower_camel_case() Is true when string and is lowercamelcase.
is_snake_case() Is true when string is underscore-delimited lowercase.
is_snake_case_file_name() Is true when string is underscore-delimited lowercase file name.
is_snake_case_file_name_with_extension() Is true when string is underscore-delimited lowercase file name with extension.
is_snake_case_package_name() Is true when string is underscore-delimited lowercase package name.
is_space_delimited_lowercase() Is true when string is space-delimited lowercase.
is_string(argument) Is true when argument is a string.
is_upper_camel_case() Is true when string upper camel case.
isalnum(() -> bool) Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise.
isalpha(() -> bool) Return True if all characters in S are alphabetic and there is at least one character in S, False otherwise.
isdecimal(() -> bool) Return True if there are only decimal characters in S, False otherwise.
isdigit(() -> bool) Return True if all characters in S are digits and there is at least one character in S, False otherwise.
isidentifier(() -> bool) Return True if S is a valid identifier according to the language definition.
islower(() -> bool) Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise.
isnumeric(() -> bool) Return True if there are only numeric characters in S, False otherwise.
isprintable(() -> bool) Return True if all characters in S are considered printable in repr() or S is empty, False otherwise.
isspace(() -> bool) Return True if all characters in S are whitespace and there is at least one character in S, False otherwise.
istitle(() -> bool) Return True if S is a titlecased string and there is at least one character in S, i.e.
isupper(() -> bool) Return True if all cased characters in S are uppercase and there is at least one cased character in S, False otherwise.
join((iterable) -> str) Return a string which is the concatenation of the strings in the iterable.
ljust((width[, fillchar]) -> str) Return S left-justified in a Unicode string of length width.
lower(() -> str) Return a copy of the string S converted to lowercase.
lstrip(([chars]) -> str) Return a copy of the string S with leading whitespace removed.
maketrans Return a translation table usable for str.translate().
normalize(argument[, indent]) Normalizes string.
partition(sep) -> (head, sep, tail) Search for the separator sep in S, and return the part before it, the separator itself, and the part after it.
pluralize([count]) Pluralizes English string.
replace((old, new[, count]) -> str) Return a copy of S with all occurrences of substring old replaced by new.
rfind((sub[, start[, end]]) -> int) Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
rindex((sub[, start[, end]]) -> int) Like S.rfind() but raise ValueError when the substring is not found.
rjust((width[, fillchar]) -> str) Return S right-justified in a string of length width.
rpartition(sep) -> (head, sep, tail) Search for the separator sep in S, starting at the end of S, and return the part before it, the separator itself, and the part after it.
rsplit((sep=None[, maxsplit]) Return a list of the words in S, using sep as the delimiter string, starting at the end of the string and working to the front.
rstrip(([chars]) -> str) Return a copy of the string S with trailing whitespace removed.
split((sep=None[, maxsplit]) Return a list of the words in S, using sep as the delimiter string.
splitlines(([keepends]) -> list of strings) Return a list of the lines in S, breaking at line boundaries.
startswith((prefix[, start[, end]]) -> bool) Return True if S starts with the specified prefix, False otherwise.
strip(([chars]) -> str) Return a copy of the string S with leading and trailing whitespace removed.
strip_diacritics() Strips diacritics from binary string.
swapcase(() -> str) Return a copy of S with uppercase characters converted to lowercase and vice versa.
title(() -> str) Return a titlecased version of S, i.e.
to_accent_free_snake_case() Changes string to accent-free snake case.
to_bidirectional_direction_string(argument) Changes argument to bidirectional direction string.
to_bidirectional_lilypond_symbol(argument) Changes argument to bidirectional LilyPond symbol.
to_dash_case() Changes string to dash case.
to_lower_camel_case() Changes string to lower camel case.
to_snake_case() Changes string to snake case.
to_space_delimited_lowercase() Changes string to space-delimited lowercase.
to_tridirectional_direction_string(argument) Changes argument to tridirectional direction string.
to_tridirectional_lilypond_symbol(argument) Changes argument to tridirectional LilyPond symbol.
to_tridirectional_ordinal_constant(argument) Changes argument to tridirectional ordinal constant.
to_upper_camel_case() Changes string to upper camel case.
translate((table) -> str) Return a copy of the string S in which each character has been mapped through the given translation table.
upper(() -> str) Return a copy of S converted to uppercase.
zfill((width) -> str) Pad a numeric string S with zeros on the left, to fill a field of the specified width.
__add__ Return self+value.
__contains__ Return key in self.
__eq__ Return self==value.
__format__((format_spec) -> str) Return a formatted version of S as described by format_spec.
__ge__ Return self>=value.
__getitem__ Return self[key].
__gt__ Return self>value.
__hash__ Return hash(self).
__iter__ Implement iter(self).
__le__ Return self<=value.
__len__ Return len(self).
__lt__ Return self<value.
__mod__ Return self%value.
__mul__ Return self*value.n
__ne__ Return self!=value.
__new__ Create and return a new object.
__repr__ Return repr(self).
__rmod__ Return value%self.
__rmul__ Return self*value.
__str__ Return str(self).

Methods

(str).capitalize() → str

Return a capitalized version of S, i.e. make the first character have upper case and the rest lower case.

String.capitalize_start()

Capitalizes start of string.

>>> abjad.String('violin I').capitalize_start()
'Violin I'

Function differs from built-in string.capitalize().

This function affects only string[0] and leaves noninitial characters as-is.

Built-in string.capitalize() forces noninitial characters to lowercase.

>>> 'violin I'.capitalize()
'Violin i'

Returns new string.

(str).casefold() → str

Return a version of S suitable for caseless comparisons.

(str).center(width[, fillchar]) → str

Return S centered in a string of length width. Padding is done using the specified fill character (default is a space)

(str).count(sub[, start[, end]]) → int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

String.delimit_words()

Delimits words in string.

Delimits words:

>>> string = abjad.String('scale degrees 4 and 5.')
>>> string.delimit_words()
['scale', 'degrees', '4', 'and', '5']

Delimits conjoined words:

>>> string = abjad.String('scale degrees 4and5.')
>>> string.delimit_words()
['scale', 'degrees', '4', 'and', '5']

Delimits lower camel case:

>>> string = abjad.String('scaleDegrees4and5.')
>>> string.delimit_words()
['scale', 'Degrees', '4', 'and', '5']

Delimits upper camel case:

>>> string = abjad.String('ScaleDegrees4and 5.')
>>> string.delimit_words()
['Scale', 'Degrees', '4', 'and', '5']

Delimits dash case:

>>> string = abjad.String('scale-degrees-4-and-5.')
>>> string.delimit_words()
['scale', 'degrees', '4', 'and', '5']

Delimits shout case:

>>> string = abjad.String('SCALE_DEGREES_4_AND_5.')
>>> string.delimit_words()
['SCALE', 'DEGREES', '4', 'AND', '5']

Works with greater-than and less-than signs:

>>> string = abjad.String('one < two')
>>> string.delimit_words()
['one', '<', 'two']

Works with exclamation points:

>>> string = abjad.String('one! two!')
>>> string.delimit_words()
['one', '!', 'two', '!']

Returns list.

(str).encode(encoding='utf-8', errors='strict') → bytes

Encode S using the codec registered for encoding. Default encoding is ‘utf-8’. errors may be given to set a different error handling scheme. Default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

(str).endswith(suffix[, start[, end]]) → bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

(str).expandtabs(tabsize=8) → str

Return a copy of S where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed.

(str).find(sub[, start[, end]]) → int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

(str).format(*args, **kwargs) → str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{‘ and ‘}’).

(str).format_map(mapping) → str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{‘ and ‘}’).

(str).index(sub[, start[, end]]) → int

Like S.find() but raise ValueError when the substring is not found.

String.is_dash_case()

Is true when string is hyphen-delimited lowercase.

>>> abjad.String('foo-bar').is_dash_case()
True

Otherwise false:

>>> abjad.String('foo bar').is_dash_case()
False

Returns true or false.

String.is_dash_case_file_name()

Is true when string is hyphen-delimited lowercase file name with extension.

>>> abjad.String('foo-bar').is_dash_case_file_name()
True

Otherwise false:

>>> abjad.String('foo.bar.blah').is_dash_case_file_name()
False

Returns true or false.

String.is_lower_camel_case()

Is true when string and is lowercamelcase.

>>> abjad.String('fooBar').is_lower_camel_case()
True

Otherwise false:

>>> abjad.String('FooBar').is_lower_camel_case()
False

Returns true or false.

String.is_snake_case()

Is true when string is underscore-delimited lowercase.

>>> abjad.String('foo_bar').is_snake_case()
True

Otherwise false:

>>> abjad.String('foo bar').is_snake_case()
False

Returns true or false.

String.is_snake_case_file_name()

Is true when string is underscore-delimited lowercase file name.

>>> abjad.String('foo_bar').is_snake_case_file_name()
True

Otherwise false:

>>> abjad.String('foo.bar.blah').is_snake_case_file_name()
False

Returns true or false.

String.is_snake_case_file_name_with_extension()

Is true when string is underscore-delimited lowercase file name with extension.

>>> string = abjad.String('foo_bar.blah')
>>> string.is_snake_case_file_name_with_extension()
True

Otherwise false:

>>> string = abjad.String('foo.bar.blah')
>>> string.is_snake_case_file_name_with_extension()
False

Returns true or false.

String.is_snake_case_package_name()

Is true when string is underscore-delimited lowercase package name.

>>> string = abjad.String('foo.bar.blah_package')
>>> string.is_snake_case_package_name()
True

Otherwise false:

>>> string = abjad.String('foo.bar.BlahPackage')
>>> string.is_snake_case_package_name()
False

Returns true or false.

String.is_space_delimited_lowercase()

Is true when string is space-delimited lowercase.

>>> abjad.String('foo bar').is_space_delimited_lowercase()
True

Otherwise false:

>>> abjad.String('foo_bar').is_space_delimited_lowercase()
False

Returns true or false.

String.is_upper_camel_case()

Is true when string upper camel case.

>>> abjad.String('FooBar').is_upper_camel_case()
True

Otherwise false:

>>> abjad.String('fooBar').is_upper_camel_case()
False

Returns true or false.

(str).isalnum() → bool

Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise.

(str).isalpha() → bool

Return True if all characters in S are alphabetic and there is at least one character in S, False otherwise.

(str).isdecimal() → bool

Return True if there are only decimal characters in S, False otherwise.

(str).isdigit() → bool

Return True if all characters in S are digits and there is at least one character in S, False otherwise.

(str).isidentifier() → bool

Return True if S is a valid identifier according to the language definition.

Use keyword.iskeyword() to test for reserved identifiers such as “def” and “class”.

(str).islower() → bool

Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise.

(str).isnumeric() → bool

Return True if there are only numeric characters in S, False otherwise.

(str).isprintable() → bool

Return True if all characters in S are considered printable in repr() or S is empty, False otherwise.

(str).isspace() → bool

Return True if all characters in S are whitespace and there is at least one character in S, False otherwise.

(str).istitle() → bool

Return True if S is a titlecased string and there is at least one character in S, i.e. upper- and titlecase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

(str).isupper() → bool

Return True if all cased characters in S are uppercase and there is at least one cased character in S, False otherwise.

(str).join(iterable) → str

Return a string which is the concatenation of the strings in the iterable. The separator between elements is S.

(str).ljust(width[, fillchar]) → str

Return S left-justified in a Unicode string of length width. Padding is done using the specified fill character (default is a space).

(str).lower() → str

Return a copy of the string S converted to lowercase.

(str).lstrip([chars]) → str

Return a copy of the string S with leading whitespace removed. If chars is given and not None, remove characters in chars instead.

(str).partition(sep) -> (head, sep, tail)

Search for the separator sep in S, and return the part before it, the separator itself, and the part after it. If the separator is not found, return S and two empty strings.

String.pluralize(count=None)

Pluralizes English string.

Changes terminal -y to -ies:

>>> abjad.String('catenary').pluralize()
'catenaries'

Adds -es to terminal -s, -sh, -x and -z:

>>> abjad.String('brush').pluralize()
'brushes'

Adds -s to all other strings:

>>> abjad.String('shape').pluralize()
'shapes'

Returns string.

(str).replace(old, new[, count]) → str

Return a copy of S with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.

(str).rfind(sub[, start[, end]]) → int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

(str).rindex(sub[, start[, end]]) → int

Like S.rfind() but raise ValueError when the substring is not found.

(str).rjust(width[, fillchar]) → str

Return S right-justified in a string of length width. Padding is done using the specified fill character (default is a space).

(str).rpartition(sep) -> (head, sep, tail)

Search for the separator sep in S, starting at the end of S, and return the part before it, the separator itself, and the part after it. If the separator is not found, return two empty strings and S.

(str).rsplit(sep=None, maxsplit=-1) → list of strings

Return a list of the words in S, using sep as the delimiter string, starting at the end of the string and working to the front. If maxsplit is given, at most maxsplit splits are done. If sep is not specified, any whitespace string is a separator.

(str).rstrip([chars]) → str

Return a copy of the string S with trailing whitespace removed. If chars is given and not None, remove characters in chars instead.

(str).split(sep=None, maxsplit=-1) → list of strings

Return a list of the words in S, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done. If sep is not specified or is None, any whitespace string is a separator and empty strings are removed from the result.

(str).splitlines([keepends]) → list of strings

Return a list of the lines in S, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true.

(str).startswith(prefix[, start[, end]]) → bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

(str).strip([chars]) → str

Return a copy of the string S with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead.

String.strip_diacritics()

Strips diacritics from binary string.

>>> binary_string = abjad.String('Dvořák')
>>> print(binary_string)
Dvořák
>>> binary_string.strip_diacritics()
'Dvorak'

Returns ASCII string.

(str).swapcase() → str

Return a copy of S with uppercase characters converted to lowercase and vice versa.

(str).title() → str

Return a titlecased version of S, i.e. words start with title case characters, all remaining cased characters have lower case.

String.to_accent_free_snake_case()

Changes string to accent-free snake case.

>>> abjad.String('Déja vu').to_accent_free_snake_case()
'deja_vu'

Strips accents from accented characters.

Changes all punctuation (including spaces) to underscore.

Sets to lowercase.

Returns new string.

String.to_dash_case()

Changes string to dash case.

Changes words to dash case:

>>> abjad.String('scale degrees 4 and 5').to_dash_case()
'scale-degrees-4-and-5'

Changes snake case to dash case:

>>> abjad.String('scale_degrees_4_and_5').to_dash_case()
'scale-degrees-4-and-5'

Changes dash case to dash case:

>>> abjad.String('scale-degrees-4-and-5').to_dash_case()
'scale-degrees-4-and-5'

Changes upper camel case to dash case:

>>> abjad.String('ScaleDegrees4And5').to_dash_case()
'scale-degrees-4-and-5'

Returns string.

String.to_lower_camel_case()

Changes string to lower camel case.

Changes words to lower camel case:

>>> abjad.String('scale degrees 4 and 5').to_lower_camel_case()
'scaleDegrees4And5'

Changes snake case to lower camel case:

>>> abjad.String('scale_degrees_4_and_5').to_lower_camel_case()
'scaleDegrees4And5'

Changes dash case to lower camel case:

>>> abjad.String('scale-degrees-4-and-5').to_lower_camel_case()
'scaleDegrees4And5'

Changes upper camel case to lower camel case:

>>> abjad.String('ScaleDegrees4And5').to_lower_camel_case()
'scaleDegrees4And5'

Returns string.

String.to_snake_case()

Changes string to snake case.

Changes words to snake case:

>>> abjad.String('scale degrees 4 and 5').to_snake_case()
'scale_degrees_4_and_5'

Changes snake case to snake case:

>>> abjad.String('scale_degrees_4_and_5').to_snake_case()
'scale_degrees_4_and_5'

Changes dash case to snake case:

>>> abjad.String('scale-degrees-4-and-5').to_snake_case()
'scale_degrees_4_and_5'

Changes upper camel case to snake case:

>>> abjad.String('ScaleDegrees4And5').to_snake_case()
'scale_degrees_4_and_5'

Returns string.

String.to_space_delimited_lowercase()

Changes string to space-delimited lowercase.

Changes upper camel case string to space-delimited lowercase:

>>> abjad.String('LogicalTie').to_space_delimited_lowercase()
'logical tie'

Changes underscore-delimited string to space-delimited lowercase:

>>> abjad.String('logical_tie').to_space_delimited_lowercase()
'logical tie'

Returns space-delimited string unchanged:

>>> abjad.String('logical tie').to_space_delimited_lowercase()
'logical tie'

Returns empty string unchanged:

>>> abjad.String('').to_space_delimited_lowercase()
''

Returns string.

String.to_upper_camel_case()

Changes string to upper camel case.

Changes words to upper camel case:

>>> abjad.String('scale degrees 4 and 5').to_upper_camel_case()
'ScaleDegrees4And5'

Changes snake case to upper camel case:

>>> abjad.String('scale_degrees_4_and_5').to_upper_camel_case()
'ScaleDegrees4And5'

Changes dash case to upper camel case:

>>> abjad.String('scale-degrees-4-and-5').to_upper_camel_case()
'ScaleDegrees4And5'

Changes upper camel case to upper camel case:

>>> abjad.String('ScaleDegrees4And5').to_upper_camel_case()
'ScaleDegrees4And5'

Returns new string.

(str).translate(table) → str

Return a copy of the string S in which each character has been mapped through the given translation table. The table must implement lookup/indexing via __getitem__, for instance a dictionary or list, mapping Unicode ordinals to Unicode ordinals, strings, or None. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

(str).upper() → str

Return a copy of S converted to uppercase.

(str).zfill(width) → str

Pad a numeric string S with zeros on the left, to fill a field of the specified width. The string S is never truncated.

Class & static methods

static String.is_string(argument)

Is true when argument is a string.

Otherwise false.

Returns true or false.

(str).maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

static String.normalize(argument, indent=None)

Normalizes string.

>>> string = r'''
...     foo
...         bar
... '''
>>> print(string)

    foo
        bar
>>> print(abjad.String.normalize(string))
foo
    bar
>>> print(abjad.String.normalize(string, indent=4))
    foo
        bar
>>> print(abjad.String.normalize(string, indent='* '))
* foo
*     bar

Returns new string.

static String.to_bidirectional_direction_string(argument)

Changes argument to bidirectional direction string.

>>> abjad.String.to_bidirectional_direction_string('^')
'up'
>>> abjad.String.to_bidirectional_direction_string('_')
'down'
>>> abjad.String.to_bidirectional_direction_string(1)
'up'
>>> abjad.String.to_bidirectional_direction_string(-1)
'down'

Returns argument when argument is ‘up’ or ‘down’.

Returns string or none.

static String.to_bidirectional_lilypond_symbol(argument)

Changes argument to bidirectional LilyPond symbol.

>>> abjad.String.to_tridirectional_lilypond_symbol(Up)
'^'
>>> abjad.String.to_tridirectional_lilypond_symbol(Down)
'_'
>>> abjad.String.to_tridirectional_lilypond_symbol(1)
'^'
>>> abjad.String.to_tridirectional_lilypond_symbol(-1)
'_'

Returns argument when argument is ‘^’ or ‘_’.

Returns string or none.

static String.to_tridirectional_direction_string(argument)

Changes argument to tridirectional direction string.

>>> abjad.String.to_tridirectional_direction_string('^')
'up'
>>> abjad.String.to_tridirectional_direction_string('-')
'center'
>>> abjad.String.to_tridirectional_direction_string('_')
'down'
>>> abjad.String.to_tridirectional_direction_string(1)
'up'
>>> abjad.String.to_tridirectional_direction_string(0)
'center'
>>> abjad.String.to_tridirectional_direction_string(-1)
'down'
>>> abjad.String.to_tridirectional_direction_string('default')
'center'

Returns none when argument is none.

Returns string or none.

static String.to_tridirectional_lilypond_symbol(argument)

Changes argument to tridirectional LilyPond symbol.

>>> abjad.String.to_tridirectional_lilypond_symbol(Up)
'^'
>>> abjad.String.to_tridirectional_lilypond_symbol('neutral')
'-'
>>> abjad.String.to_tridirectional_lilypond_symbol('default')
'-'
>>> abjad.String.to_tridirectional_lilypond_symbol(Down)
'_'
>>> abjad.String.to_tridirectional_lilypond_symbol(1)
'^'
>>> abjad.String.to_tridirectional_lilypond_symbol(0)
'-'
>>> abjad.String.to_tridirectional_lilypond_symbol(-1)
'_'

Returns none when argument is none.

Returns argument when argument is ‘^’, ‘-‘ or ‘_’.

Returns string or none.

static String.to_tridirectional_ordinal_constant(argument)

Changes argument to tridirectional ordinal constant.

>>> abjad.String.to_tridirectional_ordinal_constant('^')
Up
>>> abjad.String.to_tridirectional_ordinal_constant('_')
Down
>>> abjad.String.to_tridirectional_ordinal_constant(1)
Up
>>> abjad.String.to_tridirectional_ordinal_constant(-1)
Down

Returns argument when argument is Up’, Center or Down.

Returns ordinal constant or none.

Special methods

(str).__add__()

Return self+value.

(str).__contains__()

Return key in self.

(str).__eq__()

Return self==value.

(str).__format__(format_spec) → str

Return a formatted version of S as described by format_spec.

(str).__ge__()

Return self>=value.

(str).__getitem__()

Return self[key].

(str).__gt__()

Return self>value.

(str).__hash__()

Return hash(self).

(str).__iter__()

Implement iter(self).

(str).__le__()

Return self<=value.

(str).__len__()

Return len(self).

(str).__lt__()

Return self<value.

(str).__mod__()

Return self%value.

(str).__mul__()

Return self*value.n

(str).__ne__()

Return self!=value.

(str).__new__()

Create and return a new object. See help(type) for accurate signature.

(str).__repr__()

Return repr(self).

(str).__rmod__()

Return value%self.

(str).__rmul__()

Return self*value.

(str).__str__()

Return str(self).