Skip to content

How to store all form input in a dictionary? #1824

Answered by mturoci
ledell asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Erin.

q.args is an object of type Expando, which is just a fancy wrapper for python dict. This means

  • It's already a dict and might be good enough for your use case as is.
  • or it's possible to iterate over q.args and store them in your dict of choice for further processing.
  • or reusing existing wave Expando utils (code below).
from h2o_wave import main, app, Q, ui, copy_expando, Expando, expando_to_dict

# Convert expando to dict.
expando_dict = expando_to_dict(copy_expando(q.args, Expando()))

The last approach is considered safest for most of the scenarios since mutating the newly created dict would not change the original Expando (q.args) as well.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ledell
Comment options

Answer selected by ledell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants