[Tutor] Stuck on Something
Jörg Wölke
lumbricus@gmx.net
Thu, 8 Mar 2001 04:44:59 +0100 (MET)
> >Message: 8 Date: Wed, 7 Mar 2001 01:07:11 -0700 From: David Porter To:
> >Python Tutor Subject: Re: [Tutor] Stuck on Something Organization: (a
> >Conspiracy)
> >
> >* Britt Green :
> >
> > > Hopefully that wasn't too vague. Any suggestions?
> >
> >#---
> >
> >import string
> >
> >raw_dirs = """\ drwxrwx--- 2 restback privftp 512 Mar 6 21:23
> >technicolorkitchen drwxrwx--- 2 restback privftp 512 Mar 6 21:58
> >theclubhouse drwxrwx--- 2 restback privftp 512 Mar 6 21:07 thirdstreet
> >drwxrwx--- 2 restback privftp 512 Feb 27 11:18 thyme"""
> >
> >dirs = [] raw_dirs = string.split(raw_dirs, '\n') for x in raw_dirs:
> >dirs.append(string.split(x)[-1])
> >
> >print dirs
>
> Okay. I see what you're doing with this. Unfortunately, when I run this I
> get this error:
>
> >>>
> Traceback (innermost last):
> File "C:\Program Files\Python20\Code\anotherftpthing.py", line 22, in ?
> dirs.append(string.split(x)[-1])
> IndexError: list index out of range
Hello !!!
have you tried to slice this thing
i.e. string.split(x)[-1:]
^^
grreetz Jö!
>
> I've been playing with this for the past couple hours, but haven't quite
> figured out how to get around this.
>
> Britt
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
--
Sent through GMX FreeMail - http://www.gmx.net