Re: [Tutor] need advice on streamlining code...

2005-01-19 Thread Eric L. Howard
At a certain time, now past [Jan.17.2005-01:48:34PM -0500], elh@outreachnetworks.com spake thusly: > 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: > > insideipgre

Re: [Tutor] need advice on streamlining code...

2005-01-18 Thread Jacob S.
yeah, I wasn't sure about that readline/lines thing, cos I'm not sure how popen works. Well, I'm not positive about it either! But that doesn't mean that you can't comment out what you had, try this, and uncomment the previous if it doesn't work. I would imagine that it works because it seems to

Re: [Tutor] need advice on streamlining code...

2005-01-18 Thread Kent Johnson
Jacob S. wrote: insideipgrep = insideipgrep.lstrip("ifconfig_fxp0=\"inet ") No! The argument to lstrip() is a list of characters, any of which will be stripped! It is *not* a prefix to remove! >>> insideipgrep='ifconfig if 00=_xxx Wow' >>> insideipgrep.lstrip("ifconfig_fxp0=\"inet ") 'Wow' You

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Liam Clarke
yeah, I wasn't sure about that readline/lines thing, cos I'm not sure how popen works. On Mon, 17 Jan 2005 21:38:37 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > I seem to always be the one to suggest this, but -- > > "String methods are better than using the string module because the string > mo

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Jacob S.
I seem to always be the one to suggest this, but -- "String methods are better than using the string module because the string module has been ?deprecated? or will be soon. I think that is the word here. So, do this instead." insideipgrepfd = os.popen("grep ifconfig_fxp0 /etc/rc.conf") insideipg

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Liam Clarke
Well, if you're looking to extract the IP & mask you could use a regEx. They're not to bad If it's only that line that you're extracting, and it's format doesn't change import re pattern='ifconfig_fxp0="inet (?P*.?) netmask (?P*.?)" reObj=re.compile(pattern, IGNORECASE) jay = os.popen("

Re: [Tutor] need advice on streamlining code...

2005-01-17 Thread Chad Crabtree
I can't really think of a more elegant solution than what you have, maybe regex's but I hate those. You *can* reduce the number of lines by two, and there was a variable you never used. HTH Eric L. Howard wrote: >The following block of code works, and provides the necessary output I'm >looking

[Tutor] need advice on streamlining code...

2005-01-17 Thread Eric L. Howard
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() insideipfi