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/2005-January/051134.html below:

[Python-Dev] PEP 246: let's reset

[Python-Dev] PEP 246: let's reset [Python-Dev] PEP 246: let's resetNick Coghlan ncoghlan at iinet.net.au
Mon Jan 17 12:49:42 CET 2005
Guido van Rossum wrote:
> Typechecking can be trivially defined in terms of adaptation:
> 
> def typecheck(x, T):
>    y = adapt(x, T)
>    if y is x:
>        return y
>    raise TypeError("...")

Assuming the type error displayed contains information on T, the caller can then 
trivially correct the type error by invoking adapt(arg, T) at the call point 
(assuming the argument actually *is* adaptable to the desired protocol). The 
code inside the function still gets to assume the supplied object has the 
correct type - the only difference is that if adaptation is actually needed, the 
onus is on the caller to provide it explicitly (and they will get a specific 
error telling them so).

This strikes me as quite an elegant solution.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
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