-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PEP 536: Final Grammar for Literal String Interpolation #155
Conversation
Hello, and thanks for your contribution! Unfortunately we couldn't find an account corresponding to your GitHub username at bugs.python.org (b.p.o). If you don't already have an account at b.p.o, please create one and make sure to add your GitHub username. If you do already have an account at b.p.o then please go there and under "Your Details" add your GitHub username. And in case you haven't already, please make sure to sign the PSF contributor agreement (CLA); we can't legally look at your contribution until you have signed the CLA. Once you have done everything that's needed, please reply here and someone will verify everything is in order. |
I signed the CLA and put my github name! I’d also love if #1 could be fixed. would make it easy to provide a “rendered view” link like it’s common for rust RFCs |
Please wrap the lines at 70 or 79 characters (I haven't looked at the content). |
done! some code that i copied from PEP 498 needs to be longer. |
Version: $Revision$ | ||
Last-Modified: $Date$ | ||
Author: Philipp Angerer <[email protected]> | ||
Status: Pending |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change this to Draft so Travis testing will pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Looks like Travis is still not happy yet. |
on it. apparently you have to give it a number anyway. maybe it would make sense to provide a way to get a number before a PEP or so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .rst
extension doesn't work with python.org yet. Could you change it to .txt
please?
@@ -0,0 +1,175 @@ | |||
PEP: 999 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to use 999? I think we can use the next available number: 536 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP 12 says i have to be given one, not just pick the next one, but it seems reasonable. maybe we should fix this in PEP 12 and fix conflicts if people try to use the same number.
PEP 12 also says we can use rst already…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP 12 also says we can use rst already…
That's my fault. I thought I can finish my work by now, but due to some personal issues I couldn't find the time to work on it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry and I hope everything works out for you!
Created: 20-Sep-2016 | ||
Python-Version: 3.7 | ||
Post-History: 20-Sep-2016 | ||
Resolution: None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? can i just leave out the “Resolution” line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no point to keep an optional field now (and I don't think using None as a value makes any sense) We can always add it back when your PEP is discussed on python-ideas :)
Content-Type: text/x-rst | ||
Created: 20-Sep-2016 | ||
Python-Version: 3.7 | ||
Post-History: 20-Sep-2016 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to update this date :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
PEP 12 probably needs some updates for the new GitHub workflow. Having a contributor pick a PEP number is unlikely to have conflicts (it's not common to see two new PEPs proposed simultaneously), and as soon as one's merged, the other would show a merge conflict in git. So it's safe. |
@berkerpeksag all done |
it is easy to extend syntax highlighters to correctly parse | ||
and display f-literals: | ||
|
||
.. raw:: html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python.org (django-markitup to be exact) ignores the raw directive for security reasons. Can you change this to a plain code block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more interesting to actually include the diff of what you had to change to the syntax highlighter to make it work than the actual output as the critical aspect of your claim is it's easy to update highlighters, not that it works in the end (we can just take your word on that).
As for removing the protection, I don't think we should change how python.org functions just for this one thing (we've gone 16 years and hundreds of PEPs without allowing raw HTML and this specific example is not critical to the PEP itself anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more interesting to actually include the diff of what you had to change to the syntax highlighter to make it work
good idea, i’ll add that part!
than the actual output
seeing is believing! i really want to include that part for people who have only seen string-colored code parts until now instead of something like this!
I don't think we should change how python.org functions just for this one thing
actually @berkerpeksag was mistaken and we don’t have to change a thing. generate_pep_pages.py
says:
with “works”, it means “runs get_pep_page
” on the paths of the generated PEP HTML fragments…
…and pep2html.py
happily embeds my raw HTML
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I just tried this branch in my local python.org setup and it worked fine. I forgot we only store HTML outputs in the database. Thanks!
The only thing we need is to rename the file name to pep-0536.txt
(add a leading zero like the other PEPs)
I haven't fully read the PEP yet so I'll let Brett or Chris do the proofreading and the merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops! done, the zero’s there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brettcannon i added a paragraph about syntax highlighter implementation
Rationale | ||
========= | ||
|
||
.. https://mail.python.org/pipermail/python-ideas/2016-August/041727.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link should be at the References section, and add the thread title here (Let’s make escaping in f-literals impossible)
As mentioned in PEP 12 :)
https://www.python.org/dev/peps/pep-0012/#hyperlinks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATM it’s just a comment, but i can add it as link if you want.
by giving f-literals a regular grammar without exceptions | ||
and implementing it using dedicated parse code. | ||
|
||
.. note:: put preceding paragraph into “Rationale”? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably decide if you're going to follow through with this comment or simply remove it now as there's no need to wait on feedback for a decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Familiarity also plays a role: Arbitrary nesting of expressions | ||
without expansion of escape sequences is available in every single | ||
other language employing a string interpolation method that uses | ||
expressions instead of just variable names. [#]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do give names to your references, else it's easy to get the sequence wrong if you add a reference later on.
Python challenge” | ||
#. Syntax highlighters are good in parsing nested grammar, but not | ||
in recognizing escape sequences. ECMAScript 2016 (JavaScript) allows | ||
escape sequences in its identifiers [#]_ and the author knows of no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name your references as its easy for the order to change if you add a reference later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
in expression portions of single line strings. | ||
|
||
.. note:: Is lifting of the restrictions sufficient, | ||
or should we specify a more complete grammar? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An actual diff of Python's Grammar/Grammar
file would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you point me to another PEP where this is done so i have a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of a specific one off the top of my head. You're going to have to do this for the implementation anyway and so you can just embed the diff to the grammar file.
Reference Implementation | ||
======================== | ||
|
||
TBD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an implementation being worked on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not yet. isn’t the usual procedure to wait for feedback first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usual procedure is to ask on python-ideas if the idea seems viable, and then if it does then you do a draft PEP to python-ideas, and then if it holds up you do a rough implementation and send it along with the PEP to python-dev because that's when the question of maintenance comes into play.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. in this case people already confirmed that they think this is a good idea, but i never coded anything in C. so where do i turn to for guidance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either you ask for help upfront when you post your PEP to python-ideas and end up with a co-author or you hope that python-dev thinks your idea is so good that a core dev agrees to do it for you (but that's not very common).
I just realized I don't remember seeing this PEP sent to python-ideas and I forgot to ask that. So has this gone to python-ideas first for discussion prior to opening this PR? |
no, but the idea was born in a thread there, and all arguments already came up not in comprehensive PEP form though |
Since you need the PEP to ask for help I've gone ahead and accepted the PEP. Before you send it to python-ideas, @flying-sheep , please fork the repository and have people send changes directly to you. Once the discussion is finished on python-ideas you can send us another PR to incorporate the accumulated changes from the python-ideas discussion. |
OK, thank you! will do. i’ll tell them to comment on https://github.com/flying-sheep/peps/blob/master/pep-0536.txt |
Hi, I announced some time ago that I’d pick this up, now I’ve finally managed to write it!
I hope the general structure, phrasing, formatting and so on are OK, this is my first PEP.
rendered