[Tutor] Stuck on Something (fwd)
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Tue, 6 Mar 2001 21:19:31 -0800 (PST)
Dear Britt,
Let me forward this to the other tutors at tutor@python.org; I'll take a
look at your question later tonight, but perhaps someone else can answer
quickly in the meantime.
Talk to you later!
---------- Forwarded message ----------
Date: Tue, 06 Mar 2001 19:30:33 -0800
From: Britt Green <britt_green@hotmail.com>
To: dyoo@hkn.eecs.berkeley.edu
Subject: Stuck on Something
Howdy,
I'm kinda stuck on my program, and I think its because I'm just not sure how
to write it in Python. Let me show you the bit of code i have so far:
dirlist = ['/atl', '/boston', '/chicago']
ftp = FTP('ftp.opentable.com', 'account', 'password')
for folders in dirlist:
ftp.cwd(folders)
folderContents = getftplist(ftp)
Basically, this code goes into each of the three directories and returns, as
a string, the list of directories in each folder. It kind of looks like
this:
drwxrwx--- 2 restback privftp 512 Feb 9 21:20 vivo
drwxrwx--- 2 restback privftp 512 Mar 6 21:09 voltaire
drwxrwx--- 2 restback privftp 512 Mar 6 21:10 vong
drwxrwx--- 2 restback privftp 512 Mar 6 21:07 watusi
drwxrwx--- 2 restback privftp 512 Mar 6 21:57 wildfire
drwxrwx--- 2 restback privftp 512 Mar 6 21:35 zinfandel
So what I need to do with this chunk is to tell my program that vivo,
voltaire, vong, etc are all directories it needs to enter. The way I thought
I'd do this is to use the string.splitlines() command to split up
folderContents into a list. Then I run into the problem of trying to split
up each of the elements in the list. Its proving to be more difficult than I
thought.
I'm hoping I can pick your brain once more. I know how I'd write this in
C++, but not in Python. Any suggestions are appreciated!
Britt
--
It is pitch black. You are likely to be eaten by a grue.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com