[dpdk-dev] [PATCH] doc: fix build with python 3.8
Thomas Monjalon
thomas at monjalon.net
Wed Dec 11 11:58:33 CET 2019
10/12/2019 14:33, Robin Jarry:
> 2019-12-10, Thomas Monjalon:
> > 10/12/2019 13:00, Bruce Richardson:
> > > On Mon, Dec 09, 2019 at 10:00:00PM +0100, Thomas Monjalon wrote:
> > > > After upgrading to python-3.8.0, a syntax mismatch is revealed:
> > > >
> > > > doc/guides/conf.py:240: SyntaxWarning: "is not" with a literal.
> > > > Did you mean "!="?
> > > > if value is not '':
> > > >
> > > > Replacing "is not" with "!=" seems the right thing to do.
> > > >
> > >
> > > Since this is basically just checking for an empty string is
> > > "len(value) > 0" not more logical than either comparison against ''?
> >
> > Probably yes.
> > I don't know what is the best practice in Python. Robin, any clue?
>
> In most cases, it is shorter and cleaner to simply do:
>
> if value:
>
> which behind the scenes calls value.__bool__() (or value.__len__()).
>
> https://docs.python.org/3/reference/datamodel.html#object.__bool__
I guess it works also with python 2?
I am sending a v2 with this syntax, thanks.
More information about the dev
mailing list