Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-08 Thread Nick Coghlan
Since it's relevant: my recollection us that the current use of angle brackets in inspect.Signature is just the default use of them for "there is no canonical representation of this, but leaving them out would be misleading" (I haven't checked if the PEP says that explicitly). I previously forgot

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-07 Thread Terry Reedy
On 7/7/2013 7:35 AM, Larry Hastings wrote: On 07/07/2013 07:19 AM, Ronald Oussoren wrote: Not entirely on topic, but close enough: pydoc currently doesn't use the __signature__ information at all. Adding such support would be easy enough, see #17053 for an implementation ;-) True, it doesn't

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-07 Thread Ronald Oussoren
On 7 Jul, 2013, at 19:20, Larry Hastings wrote: > On 07/07/2013 01:42 PM, Ronald Oussoren wrote: >> On 7 Jul, 2013, at 13:35, Larry Hastings >> wrote: >> >>> On 07/07/2013 07:25 AM, Ronald Oussoren wrote: >>> Signature objects use a name in angled brackets to indicate that a param

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-07 Thread Larry Hastings
On 07/07/2013 01:42 PM, Ronald Oussoren wrote: On 7 Jul, 2013, at 13:35, Larry Hastings wrote: On 07/07/2013 07:25 AM, Ronald Oussoren wrote: Signature objects use a name in angled brackets to indicate that a parameter is positional only, for example "input()". That might be an alternative to

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-07 Thread Ronald Oussoren
On 7 Jul, 2013, at 13:35, Larry Hastings wrote: > > On 07/07/2013 07:25 AM, Ronald Oussoren wrote: >> Signature objects use a name in angled brackets to indicate that a parameter >> is positional only, for example "input()". That might be an >> alternative to adding a "/" in the argument list

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-07 Thread Larry Hastings
On 07/07/2013 07:19 AM, Ronald Oussoren wrote: Not entirely on topic, but close enough: pydoc currently doesn't use the __signature__ information at all. Adding such support would be easy enough, see #17053 for an implementation ;-) True, it doesn't use inspect.signature, it uses inspect.ge

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Ronald Oussoren
On 7 Jul, 2013, at 4:48, Larry Hastings wrote: > > If we combine that with the admittedly-new "/" indicating "all previous > parameters are positional-only", Signature objects use a name in angled brackets to indicate that a parameter is positional only, for example "input()". That might be

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread R. David Murray
On Sun, 07 Jul 2013 04:48:18 +0200, Larry Hastings wrote: > On 07/07/2013 03:04 AM, Nick Coghlan wrote: > > > > On 7 Jul 2013 10:25, "Larry Hastings" > > wrote: > > >> > > >> group > > >>> > > >>> If not None, represents which "optional parameter group" this > > parame

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Ronald Oussoren
On 6 Jul, 2013, at 19:33, Larry Hastings wrote: > > Once builtins have introspection information, pydoc can do a better job, and > Argument Clinic can stop generating its redundant prototype line. Not entirely on topic, but close enough: pydoc currently doesn't use the __signature__ informati

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Larry Hastings
On 07/07/2013 03:04 AM, Nick Coghlan wrote: On 7 Jul 2013 10:25, "Larry Hastings" > wrote: >> >> group >>> >>> If not None, represents which "optional parameter group" this parameter belongs to. Optional parameter groups are contiguous sequences of parameters that

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Nick Coghlan
On 7 Jul 2013 10:25, "Larry Hastings" wrote: > > On 07/07/2013 12:32 AM, Nick Coghlan wrote: >> >> Rather than perpetuating unwanted complexity, can't we just add a single "incomplete signature" flag to handle the legacy cases, and leave those to the docstrings? >> >> As in, if the flag is set, py

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Larry Hastings
On 07/07/2013 12:32 AM, Nick Coghlan wrote: Rather than perpetuating unwanted complexity, can't we just add a single "incomplete signature" flag to handle the legacy cases, and leave those to the docstrings? As in, if the flag is set, pydoc displays the "..." because it knows the signature

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Nick Coghlan
On 7 Jul 2013 05:22, "Larry Hastings" wrote: > > > Revisiting a four-month-old discussion: > > > On 03/19/2013 11:00 AM, Larry Hastings wrote: >> >> As for handling optional argument groups, my gut feeling is that we're better off not leaking it out of Argument Clinic--don't expose it in this stri

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-07-06 Thread Larry Hastings
Revisiting a four-month-old discussion: On 03/19/2013 11:00 AM, Larry Hastings wrote: As for handling optional argument groups, my gut feeling is that we're better off not leaking it out of Argument Clinic--don't expose it in this string we're talking about, and don't add support for it in the

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Barry Warsaw
On Mar 18, 2013, at 09:45 PM, Larry Hastings wrote: >4. Store a string that looks like the Python declaration of the signature, >and parse it (Nick's suggestion). For foo above, this would be >"(arg,b=3,*,kwonly='a')". Length: 23 bytes. Very nice. -Barry ___

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Nick Coghlan
On Tue, Mar 19, 2013 at 3:00 AM, Larry Hastings wrote: > Why not require it to be there already? Maybe more like > > def foo(arg, b=3, *, kwonly='a'): > ... > > (i.e. using Ellipsis instead of pass, so that it's clear that it's not an > empty function but one the implementation of whi

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Antoine Pitrou
Le Tue, 19 Mar 2013 03:00:45 -0700, Larry Hastings a écrit : > > As for handling optional argument groups, my gut feeling is that > we're better off not leaking it out of Argument Clinic--don't expose > it in this string we're talking about, and don't add support for it > in the inspect.Parameter

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Larry Hastings
On 03/19/2013 12:23 AM, Nick Coghlan wrote: On Mon, Mar 18, 2013 at 11:08 PM, Stefan Behnel wrote: My first idea for implementation: add a "def x" to the front and ": pass" to the end Why not require it to be there already? Maybe more like def foo(arg, b=3, *, kwonly='a'): ..

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Ronald Oussoren
On 19 Mar, 2013, at 10:24, Larry Hastings wrote: > > >>> We'd want one more mild hack: the DSL will support positional >>> parameters, and inspect.Signature supports positional parameters, so >>> it'd be nice to render that information. But we can't represent that in >>> Python syntax (or a

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Larry Hastings
On 03/19/2013 12:37 AM, Serhiy Storchaka wrote: On 19.03.13 06:45, Larry Hastings wrote: 4. Store a string that looks like the Python declaration of the signature, and parse it (Nick's suggestion). For foo above, this would be "(arg,b=3,*,kwonly='a')". Length: 23 bytes. Strip parenthesis an

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Serhiy Storchaka
On 19.03.13 06:45, Larry Hastings wrote: 4. Store a string that looks like the Python declaration of the signature, and parse it (Nick's suggestion). For foo above, this would be "(arg,b=3,*,kwonly='a')". Length: 23 bytes. Strip parenthesis and it will be only 21 bytes long. We'd want one m

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-19 Thread Nick Coghlan
On Mon, Mar 18, 2013 at 11:08 PM, Stefan Behnel wrote: > I can't see why the size would matter in any way. We're mildly concerned about the possible impact on the size of the ever-growing CPython binaries. However, it turns out that this is a case where readability and brevity are allies rather t

Re: [Python-Dev] Rough idea for adding introspection information for builtins

2013-03-18 Thread Stefan Behnel
Larry Hastings, 19.03.2013 05:45: > The original impetus for Argument Clinic was adding introspection > information for builtins [...] > On to the representation. Consider the function > >def foo(arg, b=3, *, kwonly='a'): > pass > [...] > 4. Store a string that looks like the Python d

[Python-Dev] Rough idea for adding introspection information for builtins

2013-03-18 Thread Larry Hastings
The original impetus for Argument Clinic was adding introspection information for builtins--it seemed like any manual approach I came up with would push the builtins maintenance burden beyond the pale. Assuming that we have Argument Clinic or something like it, we don't need to optimize for