_default() methods only call functions, instancemethods
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Reported by @rdgraham at enthought/traitsui#193. Original report follows.
I have noticed that if a define a _name_default() for a given trait in a traitsUI class, it only seems to be called if it is a method defined inline with `def` or a lambda. I may be misunderstanding something but it seems to me that any callable object should work.
For example I have a class SettingsLoader which defines a `__call__` method and deals with loading default values in some cases. Wrapping it in a lambda expression works but I don't know why that is necessary. eg:
``` python
class A(HasTraits):
foo = String('')
_foo_default = lambda self : SettingsLoader('foo')()
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.