Hi all, newbie question here. I'm using python 2.7. I've built my first program to pull some info off the web, process it, and build dialpeers for a cisco router. I have 2 problems - the first is the formatting of printing the gathered information to a file. It seems to be inserting a new line after the variable is written. I've searched the web, but unsure of which method could fix this issue.
Here is my code snippet: count=0 o = open('dialpeers.txt', 'w') for line in open('final.txt', 'r'): figureDpn = count + 1000 dpn = str(figureDpn) label = "dial-peer voice " + dpn o.write(label) o.write('\n') destpatt = "destination-pattern " + line + "...." o.write(destpatt) o.write('\n') o.write("description *** local outbound dialpeer ***") o.write('\n') port = "port " + p o.write(port) o.write('\n') o.write('\n') count = count + 1 Output: dial-peer voice 1000 destination-pattern 252200 .... description *** local outbound dialpeer *** port 0/1 Desired Output: dial-peer voice 1000 destination-pattern 252200.... description *** local outbound dialpeer *** port 0/1 I've just started with Python 3 weeks ago, so my code is poortly written. I would appreciate any suggestions to improve. Ed Ellerbee
-- http://mail.python.org/mailman/listinfo/python-list