Question about certain frappe calls

Hello everyone
I’ve come across a few frappe calls, that are currently not listed in the developer cheat sheet. So I would like to inquire about what exactly they do and what they are for.

First off is frappe._dict()
Usually you see something like items = frappe._dict()
This seems to be used to create and modify dictionaries. However, why would one use this instead of the regular python way of creating dictionaries? items = {}

The other one is frappe.db.escape
I assume that this one is somehow used to escape certain characters.

Kind regards,
Val

I have used frappe.db.escape to escape special character.
You are right it is used to escape special characters. If there is some data in your table in which name contains ’ or " and you are using that in your query. It will raise fatal error when query fires. To avoid that we use frappe.db.escape. About frappe._dict() i have no idea as i haven’t use it yet.

1 Like

frappe._dict() is for dict like object that exposes keys as attributes.

1 Like

I assume that means you can then pass around these keys as attributes for certain functions?

This means that you can do:

dict.key

instead of:

dict.get("key", "")
# or
dict["key"]

BUT, you can still use those methods with a frappe._dict too.

4 Likes