On Mon, Oct 19, 2009 at 08:07:47PM +0100, Alan Gauld wrote: > > "Matt Herzog" <m...@blisses.org> wrote > > >remembered that strings are immutable. > >So how was I able to change the strings for my dotted quad? > > You didn't. > > >LASTKNOWN = '173.48.204.168' > > lns = cf.readlines() > > lns = "".join(lns) > > lns = re.sub(LASTKNOWN, CURRENT, lns) > > I assume this is the line in question? > sub() returns a new string containing the substitutions. > > HTH,
Yes! It sure does help. I just discovered that my script does not exit if the CURRENT IP is the same as the LASTKNOWN IP. ------------------------------ snip -------------------------------------- CURRENT = socket.getaddrinfo(socket.gethostname(), None)[0][4][0] ------------------------------ snip -------------------------------------- Turns out the above is an unreliable way to get the IP of the interface since the machine the above is running on does not have a proper hostname and is a dhcp client on a broadband network. Anyway, I'd like a hint as to how I could convert this: ifcfg_lines = os.popen("/sbin/ifconfig fxp0").readlines() x = string.split(ifcfg_lines[3])[1] to the subprocess module. The os module is going away, right? > > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor -- The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time, and still retain the ability to function. -- F. Scott Fitzgerald _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor