stripping punctuation from tuples

Wayne Izatt wayne.izatt at _nospam_myself.com
Mon Mar 19 03:01:10 EST 2001


Is this what you're looking for?

>>> a = []
>>> a.append(('Alan Tsang',))
>>> a
[('Alan Tsang',)]
>>> a[0]
('Alan Tsang',)
>>> b = a[0]
>>> b
('Alan Tsang',)
>>> (x, y) = string.split(str(b[0]))
>>> x, y
('Alan', 'Tsang')
>>> x
'Alan'
>>> y
'Tsang'
>>>

cheerio


"Louis Luangkesorn" <lluang at northwestern.edu> wrote in message
news:3AB57F0C.594CF3E9 at northwestern.edu...
> How do you strip the punctuation from tuples?  In particular, say I have
> a tuple a[10] (which happened to come from a not very well designed
> database)
>
> >>> a[10]
> ('Alan Tsang',)
>
> How do I get something to say 'Alan Tsang'  with out the parens or the
> ','
>
> Or, what I'm really trying to do is make this so
> >>>b = breakname(a[10])
> >>>b[0], b[1]
>
> 'Alan','Tsang'
>
> I've tried to do:
> >>> d = split(str(a[0]))
> >>> d
> ["('Aaron", "Fan',)"]
> >>> d[0]
> "('Aaron"
> >>> d[1]
> "Fan',)"
>
> But that is not quite what I want.
> Many thanks.
> Louis
> --
> K Louis Luangkesorn
> lluang at northwestern.edu  http://pubweb.nwu.edu/~kll560  PGP:0xF3E2D362
>
> Whatsoever things are true, ... honest, ... just, ... pure, ... lovely,
> ... of good report; if there be any virtue, and if there be any praise,
> think on these things.
>      - motto - Northwestern University (Phil 4:8)
>





More information about the Python-list mailing list