Mpaa added a comment.
With the patch, bool(namespace) is now True when namespace is Main.
>>> import pywikibot
>>> mysite = pywikibot.Site()
>>> x=pywikibot.Link("foo", source=mysite)
>>> ns=x.namespace
>>> ns
Namespace(id=0, custom_name=u'', canonical_name=u'', aliases=[],
case=u'first-letter', content=True, nonincludable=False, subpages=True)
>>> bool(ns)
True
So explicit test vs. Namespace.MAIN is needed to discriminate if namespace is
Main or not.
Relying on namespace=0 to evaluate to False, as below does not work any
longer.
if namespace:
we are in another namespace
else:
we are in main namespace
To keep such behaviour, a `__bool__() `method might be implemented.
TASK DETAIL
https://phabricator.wikimedia.org/T104864
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: jayvdb, Mpaa
Cc: Mpaa, Sn1per, gerritbot, XZise, jayvdb, Aklapper, Xqt, pywikibot-bugs-list,
Lewizho99
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs