Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21315

Re: "Decoding unicode is not supported" in unusual situation

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: "Decoding unicode is not supported" in unusual situation
References <4f571b94$0$12037$742ec2ed@news.sonic.net> <m2obs890ge.fsf@web.de>
Date 2012-03-07 22:18 +1100
Message-ID <8762egmzfp.fsf@benfinney.id.au> (permalink)
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


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

> John Nagle <nagle@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

"Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-07 00:25 -0800
  Re: "Decoding unicode is not supported" in unusual situation deets@web.de (Diez B. Roggisch) - 2012-03-07 11:20 +0100
    Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-07 22:18 +1100
      Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-07 11:42 +0000
        Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-07 11:25 -0800
          Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-08 08:48 +1100
            Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-07 23:26 +0000
              Re: "Decoding unicode is not supported" in unusual situation Terry Reedy <tjreedy@udel.edu> - 2012-03-07 19:03 -0500
              Re: "Decoding unicode is not supported" in unusual situation Ben Finney <ben+python@benfinney.id.au> - 2012-03-08 13:18 +1100
                Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-08 14:23 -0800
                RE: "Decoding unicode is not supported" in unusual situation "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-08 22:58 +0000
                Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-09 10:11 -0800
                Re: "Decoding unicode is not supported" in unusual situation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-10 00:57 +0000
                Re: "Decoding unicode is not supported" in unusual situation John Nagle <nagle@animats.com> - 2012-03-10 22:12 -0800
                Re: "Decoding unicode is not supported" in unusual situation Neil Cerutti <neilc@norwich.edu> - 2012-03-09 13:23 +0000

csiph-web