Re: [Python-Dev] pep 362 - 5th edition

2012年6月19日 20:26:45 -0700

On Wed, Jun 20, 2012 at 12:36 PM, Yury Selivanov
<[email protected]> wrote:
> On 2012年06月19日, at 9:22 PM, Yury Selivanov wrote:
>> On 2012年06月19日, at 8:39 PM, Nick Coghlan wrote:
>>> 7. The idea of immutable Signature objects does highlight an annoyance
>>> with the "attribute may be missing" style APIs. To actually duplicate
>>> a signature correctly, including its return annotation (and assuming
>>> the attribute is renamed), you would have to do something like:
>>>
>>>  try:
>>>    note = {"annotation": old_sig.annotation}
>>>  except AttributeError:
>>>    note = {}
>>>  new_sig = Signature(old_sig.parameters[1:], **note)
>
> BTW, we don't have slices for OrderedDict. Since the slice object is
> not hashable, we can implement it safely. I can create an issue (and draft
> implementation), as I think it'd be quite a useful feature.
No need, my example was just wrong, it should be:
new_sig = Signature(old_sig.parameters.values()[1:])
The constructor accepts an iterable of Parameter objects rather than a mapping.
Cheers,
Nick.
-- 
Nick Coghlan  |  [email protected]  |  Brisbane, Australia
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to