Is it important you follow exactly the same convention of creating a default string with placeholder spots and then fill those in later?
If not, you could simply use joinpath or join.
some_url(a, b) = joinpath("https://...", a, b)
If it is vitally important to follow that convention, you could create your own string type that has a format method defined on it that replaces placeholder tokens (e.g. {}) with whatever else. It wouldn’t be too hard to do (probably what Formatting does as well) but seems like more trouble that it’s worth.
You could also do the formatting manually with findfirst/next and replace…
It’s not; Formatting.jl does it in a really general way too that duplicates all of pythons formatting options. If you don’t want to use any dependency whatsoever, you could always lift parts of their source code into your own module, or base a simpler version (for interpolation only) on it. Check out the source file for ideas.
You could slightly generalize the joinpath solution I gave if you want different strings and different interpolation spots. It’s still as rigid and inflexible as you can possibly get though:
url1 = (a, b) -> joinpath("https://...", a, b)
url2 = a -> "https://discourse.julialang.org/" * a * "/baz"
url3 = (a...) -> joinpath("etc.", a...)
url1("foo", "bar")
url2("here")
url3("etc", "etc", "etc")
I’m not exactly sure what you have against the package Formatting? Why don’t you want to use external packages? Because this seems like exactly what you want:
using Formatting
DEFAULT_STRING = FormatExpr("https://...{}/{}")
url = format(DEFAULT_STRING, "foo", "bar")
If you really don’t want to use an “external” package Formatting.jl is open source, you could go find the specific methods you actually need and put them into your own Julia file…then it’s not an external package. The files are licensed under the MIT “Expat” license so I think that would be legal.
Ah I did not see your original problem with the string vs print! Whenever you encounter something like that, you can use sprint to capture the printout as a string (it’s quite a useful trick!)