Support for dict unpacking (object spread equivalent)

Abierto
#820 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
deno, javascript, python
Área
compilers

Línea de trabajo

Start with the testme.py examples in the issue and reproduce both the Python result and the Transcrypt compilation failure, then inspect the compiler entry point used by transcrypt. Verify that dict unpacking compiles and that the generated JavaScript produces {'a': 1, 'b': 2} when run with Deno.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

IS: enhancement PRIO: 3 nice

It would be nice to support dict unpacking {**a, "b": 2}, the Python equivalent to JavaScript object spread { ...a, b: 2}.

# testme.py
a = {"a": 1}
b = {**a, "b": 2}
print(b)
% python testme.py 
{'a': 1, 'b': 2}
% transcrypt testme.py        

Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.9.0
Copyright (C) Geatec Engineering. License: Apache 2.0


Saving target code in: ./__target__/org.transcrypt.__runtime__.js
Saving minified target code in: ./__target__/org.transcrypt.__runtime__.js

Error while compiling (offending file last):
        File 'testme', line 3, namely:

        Error while compiling (offending file last):
        File 'testme', line 3, namely:


Aborted

Using dict with kw args compiles but doesn't work:

# testme.py
a = {"a": 1}
b = dict(**a, **{"b": 2})
print(b)
% python testme.py 
{'a': 1, 'b': 2}
% transcrypt testme.py 

Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.9.0
Copyright (C) Geatec Engineering. License: Apache 2.0



Ready

% deno run __target__/testme.js
error: Uncaught ReferenceError: adict is not defined
    at file://./__target__/testme.js:3:316

Lenguaje dominante
Python
Estrellas
2.9k
Forks
218
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TranscryptOrg/Transcrypt

Todos los issues de TranscryptOrg/Transcrypt

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.