kalekundert / byoc

MIT License
0 stars 0 forks source link

Default factory with self argument #10

Closed kalekundert closed 3 years ago

kalekundert commented 3 years ago

I find myself somewhat often wanting default values that depend on other attributes of the object, e.g. the default output path is a function of the input path, etc. The way to do this currently is to use the get argument:

appcli.param(
    '--output',
    default=None,
    get=lambda self, x: x or self.path.with_suffix('.out'),
)

However, this is less-than-ideal for two reasons:

Possible solutions:

kalekundert commented 3 years ago

Closing this in favor of #12, which addresses the issue in a more comprehensive way.