[Tutor] Re: quicker .strip?

Lee Harr missive at hotmail.com
Fri Jan 9 15:47:36 EST 2004


>I get the info as a list, with each
>IP surrounded by ( and "  i.e. (("10.1.1.205"),("10.1.1.206"))  and I'm
>using strip() several times to get rid of the excess so that I can
>re-use the IP address when gathering my data.


Not sure what you mean, exactly.
If I put what you wrote in to python, i get ...

>>>a=(("10.1.1.205"),("10.1.1.206"))
>>>a
('10.1.1.205', '10.1.1.206')


Are they strings?  like ...

ips = ['("10.1.1.205")', '("10.1.1.206")']
?

In that case, I would probably do something like ...

>>>stripped = [ip[2:-2] for ip in ips]
>>>stripped
['10.1.1.205', '10.1.1.206']

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the Tutor mailing list