[Tutor] Removing Null Elements from a List

Britt Green britt_green@hotmail.com
Fri, 09 Mar 2001 22:57:38 -0800


If I have a list that looks like:

[None, None, None, None, None, None, None, None, None, None, 
['/atl/horseradishgrill_1'], None, None, None, None, None, None, None, None, 
None, None, None, None, None, None, None, None, None, None, 
['/boston/archive'], None, None, None, ['/boston/cafe_fleuri'], None, None, 
None, None, None, None, None, None, None, None, ['/boston/rplace'], 
['/boston/salamander'], None, ['/boston/test'], ['/boston/the_federalist'], 
None, ['/boston/yanks']]

How can I remove those None elements in it? The code that I'm getting that 
from is, in part, this:

    chosen = []
    badFiles = []


    pick = re.compile(theDate)
    for elements in files:
        if pick.search(elements):
            chosen.append(elements)
            #print chosen

    if chosen == []:
        #print ftp.pwd()
        badFiles.append(ftp.pwd() )
        return badFiles

Basically, if a directory listing from an FTP site does *not* have a file 
with today's date on it, it should be added to the list badFiles. Since some 
directories are fine, they're being added as None. How can I either stop 
this, or just remove them from the final list. Either solution would work 
just as well for me.

Thanks for the continued help. I appreciate it.

Britt
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com