Ask Your Question
0

Is there any difference between the variables b and *b in these two statements? If so, what is it?

asked 2018-10-16 08:54:43 -0600

damodar gravatar image
        (a, b, c) = 1, 2, 3
        (a, *b, c) = 1, 2, 3
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2018-10-17 00:33:16 -0600

nbruin gravatar image

The second is a syntax error in Python 2. In Python 3, the second one is valid. To see the difference, print b after both cases and compare. Hint: (a, *b, c) = (1,2,3,4) does not give an error.

This is really a python question. It has very little to do with sage specifically (especially because it doesn't quite run flawlessly on python 3 yet).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-10-16 08:54:43 -0600

Seen: 56 times

Last updated: Oct 16 '18