A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-June/120449.html below:

[Python-Dev] pep 362 - 5th edition

[Python-Dev] pep 362 - 5th editionYury Selivanov yselivanov.ml at gmail.com
Wed Jun 20 05:51:56 CEST 2012
On 2012-06-19, at 10:16 PM, Nick Coghlan wrote:
> On Wed, Jun 20, 2012 at 11:22 AM, Yury Selivanov
> <yselivanov.ml at gmail.com> wrote:
>> On 2012-06-19, at 8:39 PM, Nick Coghlan wrote:
>>> If we even keep that at all for the initial version of the API, the
>>> direct "default" and "annotation" attributes would just be read-only
>>> properties that accessed the "optional" container (reporting
>>> AttributeError if the corresponding attribute was missing)
>> 
>> +0.  I think that 'optional' is a bit unusual attribute for the stdlib,
>> but it will work if we make Signature immutable.
> 
> The name isn't great, but the mapping is a lot more convenient when
> you need to handle the case of attributes potentially being missing.


What if instead of 'optional', we have 'base_signature'
(or 'from_signature')?

    sig = signature(func)
    params = OrderedDict(tuple(sig.parameters.items())[1:])
    new_sig = Signature(params, base_signature=sig)

And for Paramater:

    param = sig.parameters['foo']

    param1 = Parameter('bar', base_parameter=param)
    param2 = Parameter('spam', annotation=int, base_parameter=param)
    param3 = Parameter(base_parameter=param)
    param4 = Parameter(default=42, base_parameter=param)

So 'base_parameter' will be a template from which Parameter's constructor
will copy the missing arguments.

-
Yury
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4