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
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