Re: convert a string to tuple
- From: Steven Bethard <steven.bethard@xxxxxxxxx>
- Date: Tue, 31 May 2005 14:47:41 -0600
querypk@xxxxxxxxx wrote:
b is a string b = '(1,2,3,4)' to b = (1,2,3,4)
py> tuple(int(s) for s in '(1,2,3,4)'[1:-1].split(',')) (1, 2, 3, 4)
Or if you're feeling daring:
py> eval('(1,2,3,4)', dict(__builtins__=None))
(1, 2, 3, 4)Python makes no guarantees about the security of this second one though.
STeVe .
- References:
- convert a string to tuple
- From: querypk
- convert a string to tuple
- Prev by Date: Re: convert a string to tuple
- Next by Date: Re: convert a string to tuple
- Previous by thread: Re: convert a string to tuple
- Next by thread: Re: convert a string to tuple
- Index(es):