urlparse isn't working?

Dale Strickland-Clark dale at riverhall.NOTHANKS.co.uk
Wed Jul 31 16:35:05 EDT 2002


This doesn't seem right to me:

>>> import urlparse
>>> urlparse.urlparse('www.wibble.com/wibble/wibble.jpg', 'http:')
('http:', '', 'www.wibble.com/wibble/wibble.jpg', '', '', '')

According to the help file:
===
Example: 

urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')
yields the tuple 

('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '')
===

it should split the host from the path.

I've tried different values for the second parameter (called
'default_scheme') with the same result.

However, if you add "http://" to the url, it starts to behave:

>>> urlparse.urlparse('http://www.wibble.com/wibble/wibble.jpg')
('http', 'www.wibble.com', '/wibble/wibble.jpg', '', '', '')

So what is the point of the 'default_scheme' if it needs to be on the
url to work properly? 

Or have I got confused?
--
Dale Strickland-Clark
Riverhall Systems Ltd



More information about the Python-list mailing list