Is there a best practice for encoding things that ...
# ask-community
d
Is there a best practice for encoding things that are not
[A-Za-z0-9_]+
as dagster names? I find myself doing shenanigans like:
Copy code
def query_literal_to_dagster_name(s):
    return (
        s.replace(":", "___colon___")
        .replace('"', "___quote___")
        .replace(" ", "___space___")
        .replace("(", "___openparen___")
        .replace(")", "___closeparen___")
        .replace(".", "___period___")
        .replace(",", "___comma___")
    )


def dagster_name_to_query_literal(s):
    return (
        s.replace("___colon___", ":")
        .replace("___quote___", '"')
        .replace("___space___", " ")
        .replace("___openparen___", "(")
        .replace("___closeparen___", ")")
        .replace("___period___", ".")
        .replace(",", "___comma___")
    )
j
Also hitting this and would be curious. Mostly with ‘-’ vs ‘_’
c
I don't think we have a guide or best practices around this tbh. Worth an issue / discussion: https://github.com/dagster-io/dagster/issues/9480
👍 1