Issue 28302: Unpacking numpy array give list (original) (raw)
Issue28302
Created on 2016-09-28 14:07 by rpampana, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg277622 - (view) | Author: RAMESH PAMPANA (rpampana) | Date: 2016-09-28 14:07 |
Unpacking numpy array gives list rather numpy array. >>> import numpy as np >>> a = np.array([1,2,3,4]) >>> x, *y, z = a >>> type(a) <class 'numpy.ndarray'> >>> type(y) <class 'list'>> >> type(x) <class 'numpy.int32'> | ||
msg277627 - (view) | Author: SilentGhost (SilentGhost) * ![]() |
Date: 2016-09-28 14:24 |
It doesn't matter what you're unpacking, *y will collect the unpacked elements into a list. | ||
msg277628 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2016-09-28 14:25 |
Yes, you are unpacking into a list, that's what the * syntax does in this context. Since the rhs can be a mix of types, there's really no other reasonable meaning for the syntax. (The same is true for tuples, by the way). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:37 | admin | set | github: 72489 |
2016-09-28 14:25:41 | r.david.murray | set | nosy: + r.david.murraymessages: + components: + Regular Expressions, - Interpreter Core |
2016-09-28 14:24:23 | SilentGhost | set | status: open -> closedcomponents: + Interpreter Core, - Regular Expressionsnosy: + SilentGhostmessages: + resolution: not a bugstage: resolved |
2016-09-28 14:07:24 | rpampana | create |