Martin Panter added the comment:

I also liked the idea of returning None to distinguish a missing URL component 
from an empty-but-present component, and it would make them more consistent 
with the “username” and “password” fields. But I agree it would break backwards 
compabitility too much. The idea of “has_fragment” etc flags might work. The 
ParseResult etc class signatures could be expanded like this:

SplitResult(scheme, netloc, path, query, fragment, *, has_netloc=None, 
has_query=None, has_fragment=None)

>>> url1 = SplitResult("http", "localhost", "/path", query="", fragment="")
>>> url1.has_netloc
True
>>> url1.has_fragment
False
>>> url2 = SplitResult("http", "localhost", "/path", query="", fragment="", 
>>> has_fragment=True)
>>> url2.has_fragment
True
>>> url2.has_query
False
>>> url2.geturl()
"http://localhost/path#";

Is it also worth adding “has_params” for urlparse()?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22852>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to