Nick Coghlan wrote:
> With a change in type.__call__() to check the class extension registry
> before calling cls.__new__(), the above would put us well on the way to
> making
> all types extensible. For example, we could make a class of our own behave
> like a dictionary, returning its keys when converted to a list, and its
> key-value pairs when converted to a dictionary:
>
> @extend(list).for_signature(MyMapping):
> def get_keys(obj)
> return obj.keys()
>
> @extend(dict).for_signature(MyMapping):
> def get_items(obj)
> return obj.items()
Oops, better make that:
@extend(list).for_signature(MyMapping):
def get_keys(obj)
return list(obj.keys())
@extend(dict).for_signature(MyMapping):
def get_items(obj)
return dict(obj.items())
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com