Gadfly uses reserved words in python. How does it do it?

I was looking at the source code for Gadfly , a python-based SQL database, and I noticed in one of the files that various methods use a reserved word as:

Code excerpt from bindings.py:

def trl1as(l,c):
    [name, as, alias] = l
    return [(name, alias)]

....

def selectname(list, context):
    [exp, as, alias] = list
    return (exp, alias)

As expected, when I tried to import this file into the python shell, it gave me a syntax error.

>>> from gadfly import bindings
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gadfly/bindings.py", line 64
    [create, view, name, namelist, as, selection] = l
                                    ^
SyntaxError: invalid syntax

How do you avoid using reserved words?

+3
source share
1 answer

Python does not allow you to create a variable with the same name as one of the keywords. Doing this is illegal in every version and will always raise SyntaxError.

, script , as . 2.5. , as Python 2.5, Python 2.4.

+3

All Articles