Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54365
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; "'',": 0.07; 'skip:\\ 20': 0.07; 'back.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'spaces': 0.09; 'def': 0.12; 'immutable,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'res': 0.16; 'retrived': 0.16; 'str):': 0.16; 'subject:Remove': 0.16; 'temp': 0.16; 'tuple': 0.16; 'tuple.': 0.16; 'wrote:': 0.18; 'all,': 0.19; "skip:' 30": 0.19; 'header:User-Agent:1': 0.23; 'format,': 0.24; 'header:X-Complaints-To:1': 0.27; 'this.': 0.32; 'probably': 0.32; 'subject:from': 0.34; 'convert': 0.35; 'done.': 0.35; 'charset:us- ascii': 0.36; 'easiest': 0.38; 'filled': 0.38; 'to:addr:python- list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'remove': 0.60; 'new': 0.61; 'skip:n 10': 0.64; '.....': 0.78; "'3',": 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: Remove \n, " " from tuple. |
| Date | Wed, 18 Sep 2013 09:03:29 +0000 (UTC) |
| References | <CAAZP3kmUnKe2BnSK2vkXijjuYiQ3ZHFUY=6A9T1iUD7z1baSNw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 174.32.174.35 |
| User-Agent | XPN/1.2.6 (Street Spirit ; Linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.111.1379495030.18130.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1379495030 news.xs4all.nl 15876 [2001:888:2000:d::a6]:43937 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54365 |
Show key headers only | View raw
On 18/9/2013 01:12, Venkat Addala wrote:
> Hi all,
>
> I have a tuple in this format, which is retrived using MySQLdb, now i want
> to remove \n and extra spaces in this.
>
> 13L, 'ssDsC', 'CEs5s1, DsC', 'srylscetsmight\nghtscetylsse', '3', '3q25.1',
> 151531861L, 151546276L, '+', '1 kjafhkfhlad\fdfdsdf ghtscetylsse \ncontends
> the sctivity of dsfdk srylsmine N-scetyltrsnsfersse thst scts ss s cstslyst
> inbiotrsnsformstion fghjfg for srylsmine snd bvhghbh smine csrcinogens.
> Bgskjdg in ssDsC dfkdkdf in bresst snd prostrste csncer.', '', 'Msdhurs
> \nsgdfgssssvslingegowds', dstetime.dste(2013, 6, 14), None
>
A tuple is immutable, so it cannot be done.
However, you can create a new tuple. Easiest way is probably to convert
it to a list, process any strings in the list, and convert it back.
def convert(mylist):
res = []
for item in mylist:
if isinstance(item, str):
item = ............ to be filled in
res.append(item)
return res
mytuple = .....
temp = list(mytuple)
mytuple = tuple(convert(temp))
--
DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Remove \n, " " from tuple. Dave Angel <davea@davea.name> - 2013-09-18 09:03 +0000
csiph-web