pytago
pytago copied to clipboard
python unpack convert error
Describe the bug A clear and concise description of what the bug is.
tuple unpack
Python code example The simplest possible Python code example to demonstrate the bug.
def main():
zz,*x = (0,0,0,0)
print(zz,x)
if __name__ == '__main__':
main()
Current behavior What the program currently outputs for the code example.
package main
import "fmt"
func main() {
zz, x := 0, 0, 0, 0
fmt.Println(zz, x)
}
Expected behavior A clear and concise description of what you expected to happen.
x becomes a tuple.
Go code example Optional. An example of a satisfactory Go code output for the Python example.
this may helps
https://stackoverflow.com/questions/19832189/unpack-slices-on-assignment
The only way to do this in Go would be:
package main
import "fmt"
func main() {
zz := 0
var x []int
x = append(x, 0, 0, 0)
fmt.Println(zz, x)
}
I don't know how easy this would be to implement, but it seems like it would be pretty difficult.
Actually, I just realized, there is a better way that's probably a bit easier:
package main
import "fmt"
func main() {
zz, x := 0, []int{0, 0, 0}
fmt.Println(zz, x)
}
Don't know how I didn't think of this before