Is there a better way to unpack a table row into dictionary

What I’m trying to do:
Retrieve a table of values base on a user match into a dictionary instead of a app_table object with a single line of code.

What I’ve tried and what’s not working:
I tried to use **settings to unpack it but doesn’t seem to access the dictionary in the object.

so currently I have to hard code and setup the dictionary, I have the dictionary match the column names in my table.

1 Like

You can just do dict(settings) (I think).

For more complicated things, there’s Serialisation — Anvil Extras documentation

1 Like

awesome thanks, dict(settings) worked

2 Likes

Just a quick FYI:

Even most IDE’s with a linter installed will flag this, it is better written as :

if settings is not None:

== and != check equivalence (do the objects contain the same ultimate value), and is checks whether two objects are the “same” as in they point to (reference) the same exact location in memory.

None is a singleton, which is one of the main reasons is is preferred.

Edit:
Just to point out if you try this, if you have two objects with the same value in the same scope, python will give them the same memory location in most instances until they no longer match, obviously.
If you put them inside other memory structures (like a list) they will return False when faced with an is check.

Example:
image
image

1 Like

Love this, always knew is not was preferred, but this clarifies the why great. Thank you!

:wink:

2 Likes

awesome thanks for the tip.