Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84489

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

References <CAPTjJmrAQgtauH74dwCzb_-6T09D0dLVkxiGrAxJMp_OOwgS0g@mail.gmail.com> <54C3EAD1.2010501@stoneleaf.us> <CAPTjJmohdQbK9_ikh8heaMRbpJ270UW6C1AE2oNVgV_4AoYfQg@mail.gmail.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date 2015-01-24 12:35 -0800
Subject Re: Alternative to multi-line lambdas: Assign-anywhere def statements
Newsgroups comp.lang.python
Message-ID <mailman.18096.1422131746.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Jan 24, 2015 at 11:55 AM, Chris Angelico <rosuav@gmail.com> wrote:
> That's still only able to assign to a key of a dictionary, using the
> function name. There's no way to represent fully arbitrary assignment
> in Python - normally, you can assign to a name, an attribute, a
> subscripted item, etc. (Augmented assignment is a different beast
> altogether, and doesn't really make sense with functions.) There's no
> easy way to say "@stash(dispatch_table_a['asdf'])" and have that end
> up assigning to exactly that.

Obviously, nobody will be happy until you can do:

def call(*a, **kw): return lambda f: f(*a, **kw)

@call()
def x, y ():
    yield 1
    yield 2

Actually, maybe not even then.

-- Devin

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Alternative to multi-line lambdas: Assign-anywhere def statements Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-24 12:35 -0800
  Re: Alternative to multi-line lambdas: Assign-anywhere def statements Yawar Amin <yawar.amin@gmail.com> - 2015-01-24 15:00 -0800

csiph-web