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

tuple assignment to class members fails #58

Open
mpmilano opened this issue Mar 28, 2013 · 2 comments
Open

tuple assignment to class members fails #58

mpmilano opened this issue Mar 28, 2013 · 2 comments

Comments

@mpmilano
Copy link
Contributor

class c: pass
c.x, c.y = (5,6)

reports exception: can't assign to literals

this works in python. This makes solving the destructuring bind bug for classes somewhat tricky. I've worked around it, but when this is solved I'l like to remove the workaround.

@jpolitz
Copy link
Member

jpolitz commented Mar 28, 2013

Our destructuring assignment really only works with tuples of literals, I
think.

I played with that a little bit last week; to do it right we really need to
define an entire tree-walk over LHS expressions, and build an AST that
exercises a tree of iterators on the right. It's hairy stuff:

def f():
... yield 'fun'
... yield 'times'
...
[(a,b),(c,d)] = {f(), f()}
a
'fun'
b
'times'
c
'fun'
d
'times'

On Thu, Mar 28, 2013 at 1:24 AM, Matthew Milano [email protected]:

class c: pass
c.x, c.y = (5,6)

reports exception: can't assign to literals

this works in python. This makes solving the destructuring bind bug for
classes somewhat tricky. I've worked around it, but when this is solved I'l
like to remove the workaround.


Reply to this email directly or view it on GitHubhttps://github.com//issues/58
.

@jpolitz
Copy link
Member

jpolitz commented Mar 28, 2013

For the ambitious, I bet you can probably segfault Python somewhere in here
by using an LHS that has a property that calls a generator that's in the
middle of an iteration on the RHS or something similarly insane.

On Thu, Mar 28, 2013 at 1:35 AM, Joe Gibbs Politz [email protected] wrote:

Our destructuring assignment really only works with tuples of literals, I
think.

I played with that a little bit last week; to do it right we really need
to define an entire tree-walk over LHS expressions, and build an AST that
exercises a tree of iterators on the right. It's hairy stuff:

def f():
... yield 'fun'
... yield 'times'
...
[(a,b),(c,d)] = {f(), f()}
a
'fun'
b
'times'
c
'fun'
d
'times'

On Thu, Mar 28, 2013 at 1:24 AM, Matthew Milano [email protected]:

class c: pass
c.x, c.y = (5,6)

reports exception: can't assign to literals

this works in python. This makes solving the destructuring bind bug for
classes somewhat tricky. I've worked around it, but when this is solved I'l
like to remove the workaround.


Reply to this email directly or view it on GitHubhttps://github.com//issues/58
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants