attribute_repr_string¶
- odl.util.utility.attribute_repr_string(inst_str, attr_str)[source]¶
Return a repr string for an attribute that respects line width.
- Parameters:
- inst_strstr
Stringification of a class instance.
- attr_strstr
Name of the attribute (not including the
'.'
).
- Returns:
- attr_repr_strstr
Concatenation of the two strings in a way that the line width is respected.
Examples
>>> inst_str = 'rn((2, 3))' >>> attr_str = 'byaxis' >>> print(attribute_repr_string(inst_str, attr_str)) rn((2, 3)).byaxis >>> inst_str = 'MyClass()' >>> attr_str = 'attr_name' >>> print(attribute_repr_string(inst_str, attr_str)) MyClass().attr_name >>> inst_str = 'MyClass' >>> attr_str = 'class_attr' >>> print(attribute_repr_string(inst_str, attr_str)) MyClass.class_attr >>> long_inst_str = ( ... "MyClass('long string that will definitely trigger a line break')" ... ) >>> long_attr_str = 'long_attribute_name' >>> print(attribute_repr_string(long_inst_str, long_attr_str)) MyClass( 'long string that will definitely trigger a line break' ).long_attribute_name