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/051217.html below:

[Python-Dev] Updated Monkey Typing pre-PEP

[Python-Dev] Updated Monkey Typing pre-PEPMark Russell marktrussell at btopenworld.com
Thu Jan 20 13:33:05 CET 2005
On Thu, 2005-01-20 at 11:07, Guido van Rossum wrote:
> I'd also like to explore ways of creating partial interfaces on the
> fly. For example, if we need only the read() and readlines() methods
> of the file protocol, maybe we could declare that as follows::
> 
>   def foo(f: file['read', 'readlines']): ...
> 
> I find the quoting inelegant, so maybe this would be better::
> 
>   file[file.read, file.readlines]

Could you not just have a builtin which constructs an interface on the
fly, so you could write:

    def foo(f: interface(file.read, file.readlines)): ...

For commonly used subsets of course you'd do something like:

    IInputStream = interface(file.read, file.readlines)

    def foo(f: IInputStream): ...

I can't see that interface() would need much magic - I would guess you
could implement it in python with ordinary introspection.

Mark Russell

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