-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
f-string support #1
Comments
This would be nice, though I can't say I want to tackle the actual implementation myself. Regarding the syntax itself, we currently have Having As I see it, we'll need to pick between:
I currently see that second option as the lesser evil. |
One could probably actually use a space as delimiter and stop the previous expression wherever the parser says it's done. But that could also be confusing. Like I'm also not sure if mixing annotation and format directly makes so much sense, as in |
Another idea, what about |
Hmm, on the face of it that seems like it could work nicely, I just have two reservations:
|
With
Yeah it wouldn't do that, but any other character you choose will already have a Julia meaning as well, so you don't really avoid the problem, given that anything in there might also be just a syntax error by the user. |
The @zsz00's question doesn't seem related to styled printing at all, it only concerns string formatting. And we have this exact f-string syntax, for years already: julia> using PyFormattedStrings
julia> a="world"
"world"
julia> f"hello {a}"
hello world
julia> b=1.234567
1.234567
julia> c = f"number {b:.3f}"
"number 1.235" |
@aplavin Yep, we do already have formatting options. The way I'm interpreting this issue though is as a request for a convenient way to mix formatting specifications and string styling. |
This is step #1 to eliminating our type-piracy problems StyledStrings needs to put some type that it owns into its AnnotatedStrings so that we have a right to hook into the display logic (and the display logic can know which copy of StyledStrings to delegate to. It is also a semantic change to how constructing StyledStrings behaves, but overall I think it's a lot more intuitive to have a StyledString actually compute its style information at construction Resolves #87
Hope to have f-string like in python
reference:
https://peps.python.org/pep-0498/
https://realpython.com/python-f-strings/
https://github.com/bicycle1885/Fmt.jl
small example:
Most important of all f-string enables a compact and expressive syntax which is clean, fast and fun to type.
The text was updated successfully, but these errors were encountered: