Environment variable as value not string

Hi
currently when I specify an environment variable the content is always set as string and not as a value, for example the pair DEBUG and True is equivalent to DEBUG=‘True’, while I need DEBUG=True
Is this possible?
Many thanks

Hi,

I’m not quite sure what you mean. Setting an environment variable on a Render service dashboard will be a string. It doesn’t need to be wrapped in quotes. Is this related to your other topic?

Alan

Hi Alan
thanks for getting back to me, the other topic is not related. Yes at the moment when setting the environment variable on Render service dashboard the content will be a string what I need is not to be a string. For example f I set the variable as 1 it should not be as string 1 but as numeric value, is this possible?
Many thanks

Env vars aren’t typed. DEBUG=True sounds like a Django thing, and it knows how to read that env var.

If you want specific language typing for an env var value, you’d need to do it in your code, e.g., in Python, something like:

With env vars of

DEBUG=True
SOME_NUMBER=3
from distutils.util import strtobool

boolean_value = bool(strtobool(os.environ["DEBUG"]))
number_value = int(os.environ["SOME_NUMBER"])

Alan

Thank you Alan again, I wanted to avoid having that code but it seems that’s the only way to do it
thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.