Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'assignment': 0.07; 'suppose': 0.07; '%s"': 0.09; 'here?': 0.09; 'identifier': 0.09; 'lost.': 0.09; 'def': 0.12; '@classmethod': 0.16; 'cls': 0.16; 'mean,': 0.16; 'statement.': 0.16; 'subject:def': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'replacing': 0.19; 'thu,': 0.19; 'feb': 0.22; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; '"",': 0.31; 'implicit': 0.31; 'another': 0.32; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'problems': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'ian': 0.60; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'started.': 0.68; 'special': 0.74; 'lack': 0.78; '2015': 0.84; 'subject:Alternative': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3L6LueFmhnLDtXOLeyp4mb8lIu0l/hO9KoZGM8SOg20=; b=KkM/+Q0gRazMQP77/T55OExQlPTkJwv4nomzsDk29UpPvbSz0/ZcdGFaPIKjiAeFv/ N0QpFjrC6F0MhHbn7N1Pf3kXCvUoE10FvsnQLfrXBJAs/z8Gy3i0TcioSI6mAhKcF0jj HiYD4aREm/zK9VOEijZ8GNTKJUgXf+HYyFueb3ZmSKthW9QD8l2QhafO+5LrVNYZYfuP P5Brj/OZW7c2Lrdk5imZrHA0u9G1+XxFUk0Xuawe/cBAFKRBnpMG7lTekdPpLXbM4uda /XBcCP5yzQVYQWPlYXCFehWanRx9nqlditshZjc37+LlIIEJqozW+YTOXV/p3PAHx4cV 1biw== X-Received: by 10.66.66.166 with SMTP id g6mr7859074pat.88.1423757884863; Thu, 12 Feb 2015 08:18:04 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <54C3EAD1.2010501@stoneleaf.us> <54db5356$0$3915$e4fe514c@dreader34.news.xs4all.nl> From: Ian Kelly Date: Thu, 12 Feb 2015 09:17:23 -0700 Subject: Re: Alternative to multi-line lambdas: Assign-anywhere def statements To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423757888 news.xs4all.nl 2926 [2001:888:2000:d::a6]:56755 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85587 On Wed, Feb 11, 2015 at 8:56 PM, Chris Angelico wrote: > On Thu, Feb 12, 2015 at 1:57 PM, Ian Kelly wrote: >> The reason I don't like this replacing def isn't because the name is >> necessarily lost. It's because the lack of the well-defined def >> statement encourages more complex usages like >> >> functions['f'] = x -> x**2 >> >> where such implicit transformations won't work. > > That's actually where this started. I mean, if a function can be > called "", why can't it be called "functions['f']"? If the name isn't an identifier then it will make it harder to look up the function from the name via introspection. Another thing that might cause problems is decoration: say_hello = classmethod(cls -> print("Hello from %s" % cls.__name__)) How would the name say_hello make it all the way onto the function object here? I suppose there could be a syntax like: @classmethod say_hello = cls -> print("Hello from %s" % cls.__name__) But now the assignment statement has to be treated grammatically as a special form of assignment, just like a def statement.