Python: проинициализированный массив - (в круглых скобках)

Этот коммит содержится в:
Softonik 2022-12-08 05:13:26 +03:00 коммит произвёл Nikolay Kopitonenko
родитель 086f87df05
коммит e5f75d16b7
2 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

@ -137,7 +137,11 @@ func handleBasicLit(bl *ast.BasicLit) string {
}
func handleCompositeLit(cl *ast.CompositeLit) string {
code := "["
code := "("
switch len(cl.Elts) {
case 0:
return "[]"
default:
switch cl.Type.(type) {
case *ast.ArrayType:
args := make([]string, 0)
@ -146,7 +150,8 @@ func handleCompositeLit(cl *ast.CompositeLit) string {
}
code += strings.Join(args, ",")
}
code += "]"
}
code += ")"
return code
}

Просмотреть файл

@ -128,7 +128,7 @@ main()
expected := `from skidl import *
def main():
a = [1,2,x]
a = (1,2,x)
main()
`
Compare(source, expected)