Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can toml use variables? #528

Closed
weichangdong opened this issue Mar 16, 2018 · 4 comments
Closed

Can toml use variables? #528

weichangdong opened this issue Mar 16, 2018 · 4 comments

Comments

@weichangdong
Copy link

dir=/tmp/
dir1={dir}dir1
dir2={dir}dir2

can toml reach this effect?

@eksortso
Copy link
Contributor

It can't, and that was a deliberate design choice. Any logic, complicated or not, is best handled by the consumer of the TOML file. TOML doesn't handle that logic.

So in your case, you can configure thedir and its subdirectories in TOML, and then have your program read the TOML and compute the subdirectory paths.

# Here's an example. 
dir = '/tmp/'
subdir1 = "dir1"
subdir2 = "dir2"

You can also include comments in the TOML file so that the configuration entries make intuitive sense.

Hope that helps.

@weichangdong
Copy link
Author

got it.3q.

@Moosems
Copy link

Moosems commented Apr 17, 2023

But let's say we had a lot of information and a certain value appears a lot, wouldn't it be more readable to define it at the top of the file and then substitute in that name rather than repeat the value every single time? It would also make it easier to change all the values at once by only changing the variable instead of needing to go through each time that value is referenced and changing it there.

@eksortso
Copy link
Contributor

@Moosems Just as recently as last week, I said back in a different closed issue that you ought to propose the simple substitution idea that you had, with details that address previously raised concerns, as a new issue. Will you do that, so we can approach it fresh?

@pradyunsg Any chance we can start locking closed issues, so that the spamming will stop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants