Splitting URLs

Tim Chase python.list at tim.thechases.com
Sun Oct 21 21:53:27 EDT 2007


>> there are some goodies in urllib for doing some of this splitting. 
>> Example code at the bottom of my reply (though it seems to choke on
>> certain protocols such as "mailto:" and "ssh:" because urlparse doesn't
>> return the netloc properly)
> 
> It doesn't? That's... bad. But for my application, probably not 
> important: I only care about HTTP.

This seems to be intentional, rather than a bug.  In my
python2.4/urlparse.py file, there's a uses_netloc list which
clearly does not have 'mailto' in it.  I can't give an
explanation/justification for it, but it seems to me (IMHO) that
there is a netloc involved in a mail address.

Or maybe I have a semantic misunderstanding of what the netloc
field means when returned from urlparse.urlparse  However, since
this is where the hostname appears in "http", it makes me think
that the hostname from a mailto URL should also appear in this
result field.

-tkc








More information about the Python-list mailing list