# Add Python's f-strings (and more?) in Julia?: PEP 498 -- Literal String Interpolation

**URL:** <https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524>\
**Category:** Internals & Design\
**Tags:** proposal, strings, formatting\
**Created:** [January 16, 2017, 5:26pm UTC](https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524 "2017-01-16T17:26:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [January 16, 2017, 5:26pm UTC](https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524/1 "2017-01-16T17:26:27Z")

</div>

Is there some package with same in Julia?:

> **[What’s New In Python 3.6](https://docs.python.org/3.6/whatsnew/3.6.html#whatsnew36-pep498)**
>
> Editors, Elvis Pranskevichus \< elvis@magic.io\>, Yury Selivanov \< yury@magic.io\>,. This article explains the new features in Python 3.6, compared to 3.5. Python 3.6 was released on December 23, 2016...

[I kind of recall there’s such a package (or more than one implementing similar ideas).]

Is there value in keeping compatibility with Python as much as possible? Here, at least reserving f"…" in Julia 0.6 even if not implmented yet?

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [January 16, 2017, 5:56pm UTC](https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524/2 "2017-01-16T17:56:38Z")

</div>

Yes, my [https://github.com/ScottPJones/StringUtils.jl](https://github.com/ScottPJones/StringUtils.jl) does a lot of that, however I’m in the process of updating it and moving it an organization.  
I was planning on using f"…", and it will implement both C style and Python style formatting, along with cleaner Swift string literal syntax. (The C syntax that Julia uses has a number of issues, whereas the Swift syntax avoids them,  
and allows room for expansion).

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [January 17, 2017, 9:11am UTC](https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524/3 "2017-01-17T09:11:01Z")

</div>

> [@ScottPJones](#):
>
> it will implement both C style and Python style formatting

I meant is there value in having exactly Python’s f-style formatting, nothing more, nothing less? E.g. if someone is porting code. [In general, this could apply to other Python stuff; e.g. I know / has Python 3 semantics…]

And I probably meant then to have f-strings in Base. [Can you reserve f in Base for a future package? Would it not disallow adding that and any package trying to implement the strings later. I guess you can “reserve” informally in docs…]

Was your plan to implement f"…" then somebody else might do it (differently) and it depends on “using”?

[I guess I had [GitHub - JuliaIO/Formatting.jl: A Julia package to provide Python-like formatting support](https://github.com/JuliaIO/Formatting.jl) “Python-style Types and Functions” in mind, as one package, but it’s 3 years old, and PEP 498/Python 3.6 is brand new.]

I guess your package can implement more e.g. C"…" and Swift"…" and/or utility-functions.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [January 17, 2017, 12:05pm UTC](https://discourse.julialang.org/t/add-pythons-f-strings-and-more-in-julia-pep-498-literal-string-interpolation/1524/4 "2017-01-17T12:05:33Z")

</div>

My string literal package actually depends on a modified fork of Formatting.jl (with a set of changes from @tbreloff , and further ones from me).  
I am aware of the new PEP, and was hoping to implement a lot of that.  
I’m not really interesting in trying to implement the old style Python printing which is positional, like C’s printf, because I think it is better to have the format specification at the same place as the expression being formatted, which is what I allow using an extended interpolation syntax (which starts with , like Swift).  
The part that I got from Tom’s PR that never got merged into Formatting.jl, is type based settable defaults, so that  
you can set how you want values of a particular type to be formatted, with what padding, precision, etc. This is very powerful)
