Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'tree': 0.05; 'subject:Python': 0.06; 'string': 0.09; 'decorator': 0.09; 'expected.': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'argument,': 0.16; 'ast': 0.16; 'bool': 0.16; 'callable.': 0.16; 'email name:"': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'int)': 0.16; 'string:': 0.16; 'syntax,': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'mechanism': 0.19; 'normally': 0.19; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'either.': 0.24; 'parse': 0.24; 'paul': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'rest': 0.29; 'am,': 0.29; 'skip:@ 10': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; '25,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'extend': 0.32; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'module.': 0.36; "didn't": 0.36; 'being': 0.38; 'e.g.': 0.38; 'rather': 0.38; 'extremely': 0.39; 'catch': 0.60; 'hints': 0.68; 'receive': 0.70; '2015': 0.84; 'subject:Solution': 0.84; 'subject:Proposal': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=h8kzjRXEkvJTTxHGWJdpqAWCMWZef9TiBIBrnmaGxU4=; b=TkKgb4GHDWgMD8Y84akfyc8GNvodSALTVKpbNkA4CHwLuxNStlldrTLgEgFqvz/ED2 yVfwjCBvwmsGY2YCpvTy0WsXVDJzczRJ9c/TrsId9ggMyGq0Il96BHl1F/K0hP8qfHvk 4+GTI2nEojGV7fDE7c1s/Y/j81YWxGWs0ouRpN2htLRdxL4qnRUP0156lJ+IisU3VF3q MN0jVTGyydT86Ub9LsbA+iTXtQYeNbNEb2TULqGLr0cjnw7EOEqlklFkIxGj8IKEvT7l YTQQbRwjK41pbu3wfBMphuY+dOEvudeIBxI/F9pGPIyocvggxTvS5edTUKdnyrPIg3f0 er9w== MIME-Version: 1.0 X-Received: by 10.224.128.196 with SMTP id l4mr27322002qas.100.1422129550773; Sat, 24 Jan 2015 11:59:10 -0800 (PST) In-Reply-To: <87bnlo5bbz.fsf@jester.gateway.sonic.net> References: <6da1eb58-a0bb-4d37-8293-0a8cafe6a89c@googlegroups.com> <5afad59b-5e8c-4821-85cf-9e971c8c7be6@googlegroups.com> <4b3b498a-c9b0-443d-8514-87ccd8e98f43@googlegroups.com> <54c39e48$0$12996$c3e8da3$5496439d@news.astraweb.com> <7db16477-1dd6-4f93-adfe-54f7b7a690b2@googlegroups.com> <54c3d5d0$0$12977$c3e8da3$5496439d@news.astraweb.com> <87bnlo5bbz.fsf@jester.gateway.sonic.net> Date: Sun, 25 Jan 2015 06:59:10 +1100 Subject: Re: Python Sanity Proposal: Type Hinting Solution From: Chris Angelico Cc: "python-list@python.org" 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422129558 news.xs4all.nl 2847 [2001:888:2000:d::a6]:45663 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84488 On Sun, Jan 25, 2015 at 4:37 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> versus any other decorator, but the STRING: >> "@typehint(...)" >> being used where a decorator would normally be expected. > > I didn't catch that either. I think if hints are to go in decorators, > then it's best to extend the decorator mechanism to allow arbitrary > syntax, e.g. > > @-typehint (str, int) -> bool > > The @- would signify that the typehint function is to receive an AST as > its argument, rather than its callable. The AST would be the parse tree > for the rest of the line. Alternatively, it could get the line as a > string and parse it with appropriate functions from the ast module. That seems extremely messy. Why not use what can already be done? Since you talk about getting the line as a string... @typehint("(str, int) -> bool") ChrisA