Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8542
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <EEllerbee@BBandT.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'newbie': 0.03; 'formatting': 0.07; 'written.': 0.07; 'python': 0.08; 'newline': 0.09; 'message-----': 0.12; 'subject:file': 0.13; 'wrote:': 0.15; "'w')": 0.16; 'condense': 0.16; 'inserting': 0.16; 'router.': 0.16; 'subject:variable': 0.16; 'subject:writing': 0.16; 'thru': 0.16; 'too)': 0.16; 'edward': 0.16; 'cc:addr:python- list': 0.16; 'pm,': 0.16; 'thanks!': 0.17; 'suggest': 0.17; 'file)': 0.19; 'cc:': 0.19; 'issue.': 0.19; 'seems': 0.20; 'variable': 0.21; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'unsure': 0.23; 'tue,': 0.23; 'code': 0.24; '(or': 0.25; 'hall': 0.26; 'string': 0.26; 'function': 0.26; 'fine': 0.26; "i'm": 0.27; 'all,': 0.28; 'start,': 0.29; 'fix': 0.29; 'cc:addr:python.org': 0.30; 'subject:': 0.30; 'researching': 0.30; 'file.': 0.32; "i'll": 0.33; 'skip:" 20': 0.33; 'list.': 0.33; "i've": 0.33; 'sent:': 0.34; '\xa0\xa0\xa0': 0.34; 'example,': 0.35; 'thank': 0.35; 'question': 0.35; 'from:': 0.36; 'skip:o 20': 0.36; 'file': 0.36; 'issue': 0.37; 'instead.': 0.37; 'pull': 0.37; 'some': 0.37; 'listed': 0.37; 'but': 0.37; 'could': 0.37; 'using': 0.37; 'subject:: ': 0.38; 'problems': 0.38; 'web,': 0.39; 'where': 0.40; 'more.': 0.61; '1000': 0.62; 'here': 0.66; 'here.': 0.66; 'voice': 0.69; 'june': 0.69; 'cisco': 0.73; '12:18': 0.84; '2.7.': 0.84; 'perfect,': 0.84; 'wildcard': 0.84 |
| X-Server-Uuid | 7C9F3A3D-0A58-4F63-8FA5-251C0509CB4B |
| X-MimeOLE | Produced By Microsoft Exchange V6.5 |
| Content-class | urn:content-classes:message |
| MIME-Version | 1.0 |
| Subject | RE: Suppressing newline writing to file after variable |
| Date | Tue, 28 Jun 2011 13:32:48 -0400 |
| In-Reply-To | <BANLkTikpXEpgjvVsVWocw5wVVqnLmQDa5A@mail.gmail.com> |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| Thread-Topic | Suppressing newline writing to file after variable |
| Thread-Index | Acw1rxCI3QX6muYoTvCbjtreK9MkYgACWW4w |
| References | <77AE044B1BF3944FAE2435F395F11B4B016A2910@clt-exmb02.bbtnet.com> <BANLkTikpXEpgjvVsVWocw5wVVqnLmQDa5A@mail.gmail.com> |
| From | "Ellerbee, Edward" <EEllerbee@BBandT.com> |
| To | "Noah Hall" <enalicho@gmail.com> |
| X-OriginalArrivalTime | 28 Jun 2011 17:32:50.0334 (UTC) FILETIME=[673043E0:01CC35B9] |
| X-CFilter-Loop | Reflected |
| X-WSS-ID | 6214CE331ZO749156-01-01 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.483.1309282386.1164.python-list@python.org> (permalink) |
| Lines | 68 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1309282386 news6.xs4all.nl 4365 [2001:888:2000:d::a6]:49545 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8542 |
Show key headers only | View raw
Thank you!
That works perfect, I'll have to look into string formatting more.
My next issue to solve I've been researching is:
How to condense a group of numbers to a wildcard list. For example:
252205
252206
252208
252220
252221
252222
252223
919745
919725
919785
704770 thru 704799 (all numbers listed individually in a file)
Condense to:
25220[568]
25222[0-3] (or 25222[0123] is fine too)
9197[248]5
7047[0-9][0-9]
Any recommendations on where to start, a method or function to research?
Thanks!
Edward Ellerbee
-----Original Message-----
From: Noah Hall [mailto:enalicho@gmail.com]
Sent: Tuesday, June 28, 2011 12:18 PM
To: Ellerbee, Edward
Cc: python-list@python.org
Subject: Re: Suppressing newline writing to file after variable
On Tue, Jun 28, 2011 at 5:05 PM, Ellerbee, Edward <EEllerbee@bbandt.com> wrote:
> 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 + "...."
Try line.rstrip() instead. It'll remove all newlines. Also, I suggest you use string formatting, for example,
>>>destpatt = "destination-pattern %s...." % line.rstrip()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: Suppressing newline writing to file after variable "Ellerbee, Edward" <EEllerbee@BBandT.com> - 2011-06-28 13:32 -0400
csiph-web