Skip to content

Update @named_data to use __name__ attribute when available #120

@orgadish

Description

@orgadish

named_data(*lists_of_values) currently uses str(lst[0]), but when the first value is an object with a __name__ attribute (e.g. function or class), I think it makes sense to use that instead (otherwise the memory information or the namespace of the object is included)

def my_func():
    pass

class MyClass:
    pass

print(str(my_func))
#> <function my_func at 0x0000013E234D1760>
print(my_func.__name__)
#> my_func

print(str(MyClass))
#> <class '__main__.MyClass'>
print(MyClass.__name__)
#> MyClass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions