[Python-ideas] Verbatim names (allowing keywords as names)
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:
> I'd like to suggest we copy C#'s idea of verbatim identifiers, but using
> a backslash rather than @ sign:
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 = 'output.txt'
$if = 'input.txt'
with open($if, 'r'):
with open(of, 'w'):
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas