Skip to content

Add sc.autoapply() #548

@cliffckerr

Description

@cliffckerr

Inspired by @kelvinburke's odict_custom, would be nice to have a function that creates a new object that automatically applies a function on set. For example:

obj = dict(a=12, b=34)
strdict = sc.autoapply(obj, func=str)
strdict['c'] = 56
print(strdict['a']) # gives '12'
print(strdict['c']) # gives '56'

Not sure if this is possible in the general case, but would be cool if it were! Related to sc.asobj().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions