On Mon, Mar 10, 2014 at 5:02 AM, Josef Holzmayr < jholzm...@the-exact-steps.net> wrote:
> Hello Alex, > > > Alex J Lennon <ajlen...@dynamicdevices.co.uk> hat am 10. März 2014 um > 12:43 > > geschrieben: > > > fwiw I'd have thought myself that string comparison should be string > > comparison (==) as if you use an object identity comparison as a string > > comparison (is), you potentially introduce opaque problems when the > > strings are the same - i.e. same bytes of data - but the objects are not > > the same for whatever reason. > > I've interpreted it roughly the same so far, but they ValueError point > seems to > valid to me too (gah, I really know why I usually avoid dynamically typed > languages!). But the solution for me in this context seems to be then to > use > something like: > > DUMMYSTRING = "foobar" > def safestringcompare(stra, strb): > return type(DUMMYSTRING) == type(stra) and type(stra) == type(strb) and > stra > == strb > Strings should be compared with ==, not is. And there's nothing that will explode if you compare against None with ==. Try it yourself. >>> "foo" == None False -- Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics
-- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto