I am parsing a log containing aliases and host names. I want to get an array containing the host name and last used alias.
I have the following code that only creates a list by hostnames:
hostnames = [] # while(parsing): # nick = nick_on_current_line # host = host_on_current_line if host in hostnames: # Hostname is already present. pass else: # Hostname is not present hostnames.append(host) print hostnames # [' foo@google.com ', ' bar@hotmail.com ', ' hi@to.you ']
I thought it would be nice to end up with something like the following:
# [[' foo@google.com ', 'John'], [' bar@hotmail.com ', 'Mary'], [' hi@to.you ', 'Joe']]
My problem is that the hostname is on such a list
hostnames = []
Is there any easy solution for this, or should I try a different approach? I always had an array with objects or structures (if python has such a thing), but I would prefer a solution to the problem with my array.
Terje source share