Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46014
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: suppress newlines in my script |
| Date | 2013-05-25 13:33 -0400 |
| Organization | > Bestiaria Support Staff < |
| References | <52c74908-8bac-498e-9549-5b9500b152f1@googlegroups.com> <b52fcbed-3ea6-4352-99de-c6274c557016@googlegroups.com> <CANy1k1i9xG7XKVDy2OjxuC6CHcsNT9noChyz9ZVPr3EYNPa+5g@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2145.1369503203.3114.python-list@python.org> (permalink) |
On Fri, 24 May 2013 21:49:24 -0600, Jason Friedman <jsf80238@gmail.com>
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/
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
suppress newlines in my script sloan949@gmail.com - 2013-05-23 13:49 -0700
Re: suppress newlines in my script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-23 19:11 -0400
Re: suppress newlines in my script sloan949@gmail.com - 2013-05-24 06:59 -0700
Re: suppress newlines in my script Dave Angel <davea@davea.name> - 2013-05-24 15:24 -0400
Re: suppress newlines in my script Jason Friedman <jsf80238@gmail.com> - 2013-05-24 21:49 -0600
Re: suppress newlines in my script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-25 13:33 -0400
csiph-web