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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com