Need simple algorithm for newbie

Thomas Weholt 2002 at weholt.org
Mon Nov 4 07:53:41 EST 2002


Don't know how optimized this is, but it's start :

import string

addresses = ['groups.google.com', 'ftp.google.com', 'ftp.google.net',
'whatever.google.org']
parsed_result = {}
for address in addresses:
    parsed_result[address[string.index(address, '.')+1:]] = None
print parsed_result.keys()

Thomas

"Jason Tudisco" <tudisco at sexmagnet.com> wrote in message
news:d1a9617c.0211040433.1eddb118 at posting.google.com...
> I have a list of domains... Some of the domain names in the list look
> like this:
>
> groups.goodle.com
>
> The information I want is just google.com. I need to know the best way
> to do this.. for .com .net .org only.. and to strip the rest of the
> garbage.. like in this case.. get rid of groups in groups.google.com
>
> I need to parse though a huge list so it has to be optimized algorithm
>
> No need to write complete code.. Just get me in the right direccion..
> Still learning python and I am not sure what would be the fastest way
> to go about it..





More information about the Python-list mailing list