maxfischer2781 / chainlet

Python module for linking generators/iterators to processing chains
MIT License
1 stars 0 forks source link

Dispatch mechanism and auto converter #10

Open maxfischer2781 opened 6 years ago

maxfischer2781 commented 6 years ago

Dispatching to specific chains for specific values allows for an easy switch/dispatch/fork/... behaviour. The dict class and its literals could easily represent it:

pre_chain >> {
  # key => chain dispatches
  str: int,
  float: round,
  # how to transform a value to derive a key
  '__transform__': type,
  # what to do if the key matches no case
  '__default__': lambda value: value  # do nothing if no key matches
} >> post_chain