Multiple assignment?

Paul Watson pwatson at knightsbridge.com
Tue Apr 22 12:59:53 EDT 2003


The os.path.split() method returns a tuple of two strings.  It yields the
result of the UNIX commands dirname and basename to isolate the directory
name and filename.  Try experimenting with the interactive mode of Python.

>>> x,y=os.path.split("now/is/the time/for/all.txt")
>>> x
'now/is/the time/for'
>>> y
'all.txt'
>>> z=os.path.split("now/is/the time/for/all.txt")
>>> z
('now/is/the time/for', 'all.txt')
>>> for item in z:
...   print item
...
now/is/the time/for
all.txt
>>> type(z)
<type 'tuple'>


"Mehta, Anish" <Anish.Mehta at enst-bretagne.fr> wrote in message
news:mailman.1050918753.29031.python-list at python.org...
> Can someone tell me the what is being done here in this line of code.
>
> dir, file = os.path.split(input)
>
> Waiting for reply
>
> Thanks
>
> Anish MEHTA
>
>






More information about the Python-list mailing list