ISISComputingGroup / lewis-ess

Let's write intricate simulators!
GNU General Public License v3.0
21 stars 19 forks source link

Handle case of __name__less callables #229

Closed MikeHart85 closed 7 years ago

MikeHart85 commented 7 years ago

Minor edge case. Some callables do not have a __name__ attribute.

For example:

class Foo(object):
    def __call__(self, x):
        print(x)

>>> foo = Foo()
>>> foo('bar')
bar
>>> foo.__name__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Foo' object has no attribute '__name__'

This applies to partials as well.

This PR will display repr(func) when func.__name__ is not available.