[Tutor] need advice on streamlining code...
Eric L. Howard
elh at outreachnetworks.com
Mon Jan 17 19:48:34 CET 2005
The following block of code works, and provides the necessary output I'm
looking for...but I have a feeling that it's working through sheer brute
force and could be better:
insideipgrepfd = os.popen("grep ifconfig_fxp0 /etc/rc.conf")
insideipgrep = insideipgrepfd.readlines()
insideipfield, insideip = string.split(string.strip(insideipgrep[0]), "=")
insideipsplit = string.split(insideip, " ")
insideipquads = string.split(insideipsplit[1], ".")
insidemaskquads = string.split(insideipsplit[4], ".")
the line in /etc/rc.conf looks like:
ifconfig_fxp0="inet 172.31.2.100 netmask 255.255.255.0"
Any and all thoughts/pointers are appreciated.
~elh
--
Eric L. Howard e l h @ o u t r e a c h n e t w o r k s . c o m
------------------------------------------------------------------------
www.OutreachNetworks.com 313.297.9900
------------------------------------------------------------------------
JabberID: elh at jabber.org Advocate of the Theocratic Rule
More information about the Tutor
mailing list