Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"this': 0.03; 'output': 0.05; '21,': 0.07; 'definitions': 0.07; 'assuming': 0.09; 'defines': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'template': 0.14; '127': 0.16; 'comma': 0.16; 'csv': 0.16; 'pairs': 0.16; 'placeholder': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'separated': 0.16; 'skip:g 120': 0.16; 'appears': 0.22; 'input': 0.22; 'print': 0.22; 'url:home': 0.24; 'looks': 0.24; 'shown': 0.26; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'getting': 0.31; 'lines': 0.31; "skip:' 10": 0.31; '255,': 0.31; 'file:': 0.31; 'fri,': 0.33; 'third': 0.33; 'except': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'two': 0.37; 'list': 0.37; 'starting': 0.37; 'filled': 0.38; 'jason': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'first': 0.61; 'address': 0.63; 'here': 0.66; 'reply': 0.66; 'sample': 0.67; '20,': 0.68; 'of:': 0.68; 'records,': 0.69; 'records': 0.73; 'fourth': 0.84; 'viable': 0.84; 'gaps': 0.93; 'hand,': 0.93; 'received:108': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: suppress newlines in my script Date: Sat, 25 May 2013 13:33:06 -0400 Organization: > Bestiaria Support Staff < References: <52c74908-8bac-498e-9549-5b9500b152f1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-221-13.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369503203 news.xs4all.nl 15983 [2001:888:2000:d::a6]:56854 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46014 On Fri, 24 May 2013 21:49:24 -0600, Jason Friedman declaimed the following in gmane.comp.python.general: > > Here are two lines from the CSV file: > > ,,172.20.{0}.0/27,172.20.{0}.32/27,172.20.{0}.64/27,29,172.20.{0}.96/27,,,,172.21.{0}.0/27,172.21.{0}.32/27,172.21.{0}.64/27,29,172.21.{0}.96/27 > > GW:,,172.20.{0}.1,172.20.{0}.33,172.20.{0}.65,,172.20.{0}.97,,GW:,,172.21.{0}.1,172.21.{0}.33,172.21.{0}.65,,172.21.{0}.97 > > > > This is the output: > > ,,,,,,,,,,,,,, > > > > ,,,,,,,,,,,,,, > > GW:,,172.20.126.129,172.20.126.161,172.20.126.193,,172.20.126.225,,GW:,,172.21.126.129,172.21.126.161,172.21.126.193,,172.21.126.225 > > > > '''''''''''''''''' > > When you say "this is the output" do you mean that is what you are > getting or that is what you want? If that is what you are getting > please reply with what you want for output. Considering that, off hand, there is no viable way to match input GW:,,172.20.{0}.1 to output GW:,,172.20.126.129 except by assuming that those are not the output for the sample input. The "first" sample input appears to be a comma separated list of IP netmask definitions in which the third octet is a placeholder to be filled in later, and the fourth octet defines the starting address of each subnet. The second input line appears to be a list if IPs, again with a placeholder for the third octet, and in which the fourth octet is the first "assignable" address in the subnet. Both (input and output) seem to have the inconsistancy of: a) Based on the GW appearing twice on a line it looks almost like there are TWO records per line b) Inexplicable gaps in the records, shown by the ,, pairs Just from the samples, most of the output can be generated algorithmically... -=-=-=-=-=- template = "172.%d.%d.%d" out = ["GW:", ""] for mnet in [ 20, 21, 22 ]: for net in [ 126, 127 ]: for snet in range(1, 255, 32): if len(out) == 6: out.extend(["", "GW:", ""]) out.append(template % (mnet, net, snet)) print ",".join(out) out = ["GW:", ""] if len(out) > 2: print ",".join(out) -=-=-=-=-=- GW:,,172.20.126.1,172.20.126.33,172.20.126.65,172.20.126.97,,GW:,,172.20.126.129,172.20.126.161,172.20.126.193,172.20.126.225 GW:,,172.20.127.1,172.20.127.33,172.20.127.65,172.20.127.97,,GW:,,172.20.127.129,172.20.127.161,172.20.127.193,172.20.127.225 GW:,,172.21.126.1,172.21.126.33,172.21.126.65,172.21.126.97,,GW:,,172.21.126.129,172.21.126.161,172.21.126.193,172.21.126.225 GW:,,172.21.127.1,172.21.127.33,172.21.127.65,172.21.127.97,,GW:,,172.21.127.129,172.21.127.161,172.21.127.193,172.21.127.225 GW:,,172.22.126.1,172.22.126.33,172.22.126.65,172.22.126.97,,GW:,,172.22.126.129,172.22.126.161,172.22.126.193,172.22.126.225 GW:,,172.22.127.1,172.22.127.33,172.22.127.65,172.22.127.97,,GW:,,172.22.127.129,172.22.127.161,172.22.127.193,172.22.127.225 -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/