componenttools.get_first_component_in_expr_with_name

abjad.tools.componenttools.get_first_component_in_expr_with_name.get_first_component_in_expr_with_name(expr, name)[source]

New in version 1.1.

Get first component in expr with name:

abjad> flute_staff = Staff("c'8 d'8 e'8 f'8")
abjad> flute_staff.name = 'Flute'
abjad> violin_staff = Staff("c'8 d'8 e'8 f'8")
abjad> violin_staff.name = 'Violin'
abjad> staff_group = scoretools.StaffGroup([flute_staff, violin_staff])
abjad> score = Score([staff_group])
abjad> componenttools.get_first_component_in_expr_with_name(score, 'Violin')
Staff-"Violin"{4}

Changed in version 2.0: Function returns first component found. Function previously returned tuple of all components found.

Changed in version 2.0: renamed scoretools.find() to componenttools.get_first_component_in_expr_with_name().

Changed in version 2.0: Removed klass and context keywords. Function operates only on component name.

This Page