Re: [Python-ideas] __dir__ in which folder is this py file

2018-05-15 Thread Rob Speer
> Are you saying that servers like Nginx or whatever your mini-server uses don’t have a way to blanket ignore files? That would surprise me, and it seems like a lurking security vulnerability regardless of importlib.resources or __init__.py files. I would think that you’d want to whitelist file

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Ethan Furman
On 05/15/2018 08:03 PM, Carl Smith wrote: On Tue, May 15, 2018 at 8:41 PM, Steven D'Aprano wrote: I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash rather than @ sign: \name would allow "name" to be used as an identifier, even if it clashes with a

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Tim Peters
[Terry Reedy] > ... > I believe avoiding tagging raw names as keywords could be done by adjusting > the re for keywords Yup - it should just require adding a negative lookbehind assertion; e.g., >>> import re >>> keypat = r"(?>> re.search(keypat, r"yup! while") <_sre.SRE_Match object; span=(5,

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Terry Reedy
On 5/15/2018 8:41 PM, Steven D'Aprano wrote: Inspired by Alex Brault's post: https://mail.python.org/pipermail/python-ideas/2018-May/050750.html I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash rather than @ sign: Not quite as heavy. \name would

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Carl Smith
> On Tue, May 15, 2018 at 8:41 PM, Steven D'Aprano > wrote: > >> Inspired by Alex Brault's post: >> >> https://mail.python.org/pipermail/python-ideas/2018-May/050750.html >> >> I'd like to suggest we copy C#'s idea of verbatim identifiers, but using >> a backslash rather

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Franklin? Lee
I assume there can't be space between the backslash and the name, to prevent ambiguity like in the following: # Is this `foo = not [1]` or `foo = \not[1]`? foo = (\ not[1]) A sampling of \ in other languages, for consideration: - Haskell: A lambda. E.g. `\x -> x+1` - TeX: A

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Guido van Rossum
I like it. I much prefer \ to $ since in most languages that use $ that I know of (Perl, shell) there's a world of difference between $foo and foo whenever they occur (basically they never mean the same thing), whereas at least in shell, \foo means the same thing as foo *unless* foo would

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Tim Delaney
On Wed, 16 May 2018 at 10:42, Steven D'Aprano wrote: > Inspired by Alex Brault's post: > > https://mail.python.org/pipermail/python-ideas/2018-May/050750.html > > I'd like to suggest we copy C#'s idea of verbatim identifiers, but using > a backslash rather than @ sign: > >

[Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Steven D'Aprano
Inspired by Alex Brault's post: https://mail.python.org/pipermail/python-ideas/2018-May/050750.html I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash rather than @ sign: \name would allow "name" to be used as an identifier, even if it clashes with a

Re: [Python-ideas] __dir__ in which folder is this py file

2018-05-15 Thread Barry Warsaw
On May 15, 2018, at 14:03, Rob Speer wrote: > Consider a mini-Web-server written in Python (there are, of course, lots of > these) that needs to serve static files. Users of the Web server will expect > to be able to place these static files somewhere relative to the

Re: [Python-ideas] Escaped braces in format specifiers

2018-05-15 Thread Eric V. Smith
I'm busy at the sprints, so I don't have a lot of time to think about this. However, let me just say that recursive format specs are supported, to a depth of 1. >>> width=10 >>> f'{"test":{width}}' 'test ' So first the string is basically expanded to: f'{"test":10}' Then the string is

Re: [Python-ideas] High Precision datetime

2018-05-15 Thread Rob Speer
On Mon, 14 May 2018 at 12:17 Chris Angelico wrote: > On Tue, May 15, 2018 at 2:05 AM, Chris Barker via Python-ideas > wrote: > > But my question is whether high precision timedeltas belongs with > "calendar > > time" at all. > > > > What with UTC and

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-15 Thread MRAB
On 2018-05-15 04:32, Tim Peters wrote: Just noting some real code I typed today where `given` works great if it allows unpacking syntax, and assignment expressions don't: while True: head, matched, s = s.partition(sep) if not matched: break Using `given`:

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Guido van Rossum
I hereby withdraw the idea. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Steven D'Aprano
On Mon, May 14, 2018 at 01:28:51PM +1200, Greg Ewing wrote: > Redefining the existing keywords could perhaps be forbidden > if you really want to protect people from shooting themselves > in the kidneys this particular way. So instead of having two classes of identifiers - those that can be

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Jacco van Dorp
While I understand the attraction, I think the clarity cost might be to high. If it's a pain to explain it to an IDE, it's an even bigger pain to explain it to people new to the language. ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Paul Moore
On 15 May 2018 at 11:07, Antoine Pitrou wrote: > On Tue, 15 May 2018 21:51:20 +1200 > Greg Ewing wrote: >> Ethan Furman wrote: >> > Part of the point of the proposal is to be able to use existing keywords >> > (at least, I thought it was). >> >>

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Antoine Pitrou
On Tue, 15 May 2018 21:51:20 +1200 Greg Ewing wrote: > Ethan Furman wrote: > > Part of the point of the proposal is to be able to use existing keywords > > (at least, I thought it was). > > Mainly it's so that *new* keywords can be added to the language > without

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Greg Ewing
Ethan Furman wrote: Part of the point of the proposal is to be able to use existing keywords (at least, I thought it was). Mainly it's so that *new* keywords can be added to the language without breaking old code. Nobody is going to want to turn one of the currently existing keywords into a

[Python-ideas] Escaped braces in format specifiers

2018-05-15 Thread Ken Kundert
The syntax for formatted string literals is given here: https://docs.python.org/3/reference/lexical_analysis.html#f-strings If you were to examine this carefully, you would see that a format_spec (the part within the braces but after the colon) can be empty or it can consist of literal