[Python-ideas] Verbatim names (allowing keywords as names)
Tim Delaney
timothy.c.delaney at gmail.com
Tue May 15 20:53:26 EDT 2018
On Wed, 16 May 2018 at 10:42, Steven D'Aprano <steve at pearwood.info> 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:
>
> \name
>
Personally, I prefer $name as originally suggested in that thread. It has
the advantage of precedence from other languages as a variable indicator
(even as far back as BASIC for me) and is more visible (which IMO is a
positive, but others may see as a negative).
In either case, I'm +1 for some way of indicating a verbatiim identifier.
But I think this doesn't look too bad:
>
>
> of = 'output.txt'
> \if = 'input.txt'
> with open(\if, 'r'):
> with open(of, 'w'):
> of.write(\if.read())
>
of = 'output.txt'
$if = 'input.txt'
with open($if, 'r'):
with open(of, 'w'):
of.write($if.read())
> maybe even nicer than if_.
>
> Some examples:
>
> result = \except + 1
>
result = $except + 1
> result = something.\except
>
result = somthing.$except
result = \except.\finally
>
result = $except.$finally
@\return
def func():
pass
@$return
def func():
pass
Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180516/0b7f36fb/attachment-0001.html>
More information about the Python-ideas
mailing list