Message316483
These are actually reasonable requests, and in fact have been brought up before and implemented:
>>> x = urlparse('http://me:mypass@example.com:800/foo;key1=value1?key2=value2#key3=value3#key4=value4')
>>> x
ParseResult(scheme='http', netloc='me:mypass@example.com:800', path='/foo', params='key1=value1', query='key2=value2', fragment='key3=value3#key4=value4')
>>> x.hostname
'example.com'
>>> x.port
800
>>> x.username
'me'
>>> x.password
'mypass'
>>> x._asdict()
OrderedDict([('scheme', 'http'), ('netloc', 'me:mypass@example.com:800'), ('path', '/foo'), ('params', 'key1=value1'), ('query', 'key2=value2'), ('fragment', 'key3=value3#key4=value4')])
Now, what this doesn't get you is the "extra" fields that are not part of the base tuple. The base tuple has the members it does for backward compatibility. So, the thing to discuss on python-ideas would be an API for namedtuple that gets you the extra fields.
None versus the empty string is not something that can happen, for backward compatibility reasons, even if there was agreement that it was better.
I'm not entirely sure why dict(x) is not supported (but I suspect it is because x is "a tuple", again for backward compatibility reasons), so you might search the archives to find out why for sure, if you are curious. |
|
Date |
User |
Action |
Args |
2018-05-13 21:58:35 | r.david.murray | set | recipients:
+ r.david.murray, Ivan.Pozdeev, bsaner |
2018-05-13 21:58:35 | r.david.murray | set | messageid: <1526248715.95.0.682650639539.issue33480@psf.upfronthosting.co.za> |
2018-05-13 21:58:35 | r.david.murray | link | issue33480 messages |
2018-05-13 21:58:35 | r.david.murray | create | |
|