jazzband / jsonmodels

jsonmodels is library to make it easier for you to deal with structures that are converted to, or read from JSON.
http://jsonmodels.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
335 stars 51 forks source link

Add `EvaluateField`. #22

Open beregond opened 10 years ago

beregond commented 10 years ago

Add field that that's value is an evaluation of some function.

Probably this feature would need to rewrite whole structure to descriptors.

hgenru commented 9 years ago

Maybe add default argument to BaseField? And default may be lambda or other function.

beregond commented 9 years ago

default could be feature for itself, intention was to calculate some value from other ones (like compute event duration based on start and end date).

hgenru commented 9 years ago

Maybe it is better to do through property?

hgenru commented 9 years ago

Such mechanisms are not very pythonic.

beregond commented 9 years ago

@hgenru - this lib started it's life as something that makes life easier when dealing with different apis and unfortunately apis sometimes ARE redundant :) Such field would allow to reduce this redundancy on your side IMO. Anyway will rethink this idea again.