Tuple Assignment Statement

Merton Campbell Crockett mcc at TO.GD-ES.COM
Fri Jul 6 23:01:06 EDT 2001


On Fri, 6 Jul 2001, Merton Campbell Crockett wrote:

> I am new to Python.  The last time that I used a high-order language was at
> university in the early Seventies when I wrote a compiler for a language
> with characteristics fairly similar to Python.  Since then, I've spent a
> significant portion of my time writing in machine and assembler languages.
> 
> Am I correct in assuming that the following assignment statement is valid.
> 
>   Scheme, Host, Path = urlparse("http://JANUS.TO.GD-ES.COM/netops/")

I, probably, should have played around before asking the question.  The
above appears to be correct except that Python requires that the number of
variables must match the number of elements in the tuple.

> If valid, would the three elements contain the following?
> 
>   Scheme:  http:
>   Host:   //JANUS.TO.GD-ES.COM
>   Path:   /netops/

Unfortunately, there is an error in the urlparse function.  I can understand
why one might strip the string that terminates the scheme and introduces the
network location.  I do not understand why the path component was changed
from "/netops/" to "/netops".

These gives raise to another question.  Why are there multiple libraries
dealing with URLs?  I had, initially, assumed that urllib would be the
appropriate library.

Merton Campbell Crockett





More information about the Python-list mailing list