polymorphism w/out signatures?

Robin Munn rmunn at pobox.com
Mon May 10 13:03:41 EDT 2004


Simon Brunning <simon at brunningonline.net> wrote:
>
> def setText(window, text, append=False):
>     # Ensure that text is a list
>     try:
>         text + ''
>         text = [text]
>     except TypeError:
>         pass
>
>     ... rest of funtion, which can assume that 'text' is a list

That would be better with an "else:" clause:

    try:
        text + ''
    except TypeError:
        pass
    else:
        test = [text]

-- 
Robin Munn
rmunn at pobox.com



More information about the Python-list mailing list