"Decoding unicode is not supported" in unusual situation

Ben Finney ben+python at benfinney.id.au
Wed Mar 7 06:18:50 EST 2012


deets at web.de (Diez B. Roggisch) writes:

> John Nagle <nagle at animats.com> writes:
>
> > I think that somewhere in "suds", they subclass the "unicode" type.
> > That's almost too cute.
> >
> > The proper test is
> >
> > 	isinstance(s,unicode)
>
> Woot, you finally discovered polymorphism - congratulations!

If by “discovered” you mean “broke”.

John, polymorphism entails that it *doesn't matter* whether the object
inherits from any particular type; it only matters whether the object
behaves correctly.

So rather than testing whether the object inherits from ‘unicode’, test
whether it behaves how you expect – preferably by just using it as
though it does behave that way.

-- 
 \     Lucifer: “Just sign the Contract, sir, and the Piano is yours.” |
  `\     Ray: “Sheesh! This is long! Mind if I sign it now and read it |
_o__)                                later?” —http://www.achewood.com/ |
Ben Finney



More information about the Python-list mailing list