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

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Wed May 16 08:13:45 EDT 2018


On 16.05.2018 02:41, Steven D'Aprano wrote:
>
> Some examples:
> 
>      result = \except + 1
> 
>      result = something.\except
> 
>      result = \except.\finally
> 

Maybe that could get combined with Guido's original suggestion by making 
the \ optional after a .?

Example:

class A ():
     \global = 'Hello'
     def __init__(self):
         self.except = 0

     def \finally(self):
         return 'bye'

print(A.global)
a = A()
a.except += 1
print(a.finally())

or with a module, in my_module.py:

\except = 0

elsewhere:

import my_module
print(my_module.except)

or

from my_module import \except
print(\except)

Best,
Wolfgang



More information about the Python-ideas mailing list