Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 3132 -- Extended Iterable Unpacking inconsistent assignment of * variable #82697

Open
cigani mannequin opened this issue Oct 18, 2019 · 2 comments
Open

PEP 3132 -- Extended Iterable Unpacking inconsistent assignment of * variable #82697

cigani mannequin opened this issue Oct 18, 2019 · 2 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@cigani
Copy link
Mannequin

cigani mannequin commented Oct 18, 2019

BPO 38516
Nosy @stevendaprano, @cigani

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-10-18.12:11:14.454>
labels = ['3.7', 'library']
title = 'PEP 3132 -- Extended Iterable Unpacking inconsistent assignment of * variable'
updated_at = <Date 2019-10-18.12:41:04.898>
user = 'https://github.com/cigani'

bugs.python.org fields:

activity = <Date 2019-10-18.12:41:04.898>
actor = 'steven.daprano'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2019-10-18.12:11:14.454>
creator = 'mjaquier'
dependencies = []
files = []
hgrepos = []
issue_num = 38516
keywords = []
message_count = 2.0
messages = ['354881', '354886']
nosy_count = 2.0
nosy_names = ['steven.daprano', 'mjaquier']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue38516'
versions = ['Python 3.7']

@cigani
Copy link
Mannequin Author

cigani mannequin commented Oct 18, 2019

x = [1,2,3]

Case (1)
*b, = x
*b == [1, 2, 3]

Case(2)
*b, _ = x 
b = [1,2]

Is it not more logical for this to give consistent values regardless.

i.e.,

*b, = [1,2,3] ; b == [1,2]

*b, _ = [1,3,2] ; b == [1,2] ; _ == [3]

@cigani cigani mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels Oct 18, 2019
@stevendaprano
Copy link
Member

Why would they give the same result when the code is different?

#1 assign c, d, e and everything left over goes into b
*b, c, d, e, = [1, 2, 3, 4]

#2 assign c, d and everything left over goes into b
*b, c, d, = [1, 2, 3, 4]

#3 assign c and everything left over goes into b
*b, c, = [1, 2, 3, 4]

#4 assign nothing and everything left over goes into b
*b, = [1, 2, 3, 4]

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant