Why aren't colons optional?

Roy Smith roy at panix.com
Sun Jan 20 16:39:52 EST 2002


Alex Martelli <aleax at aleax.it> wrote:

> No, it would have substantially impoverished the language:
> 
> class doubleface:
>     def __getitem__(self, name):
>         return "anitem"
>     def __call__(self, *args):
>         return "acall"

Can you give me a practical example of why somebody would want to define a 
__getitem__ method for a class?



More information about the Python-list mailing list