Reputation: 227
I have a tuple: ('a',1)
When I use wx.StaticText to show it, it is always displayed like this: ('a',1)
How do I make it display like this: (a,1) ?
Note: It has to be a tuple. For some reason when I set a string to be a tuple it is always recorded along with the quotes. So:
a = (str(hello),1)
And if you print a you get:
>>>print a
('hello',1)
Upvotes: 1
Views: 163
Reputation: 369444
Instead of passing the tuple object directly, pass a string formatted:
>>> a = ('a', 1)
Using %
operator:
>>> '(%s, %s)' % a
'(a, 1)'
>>> '%s, %s' % a # without parentheses
'a, 1'
Using str.format
:
>>> '({0[0]}, {0[1]})'.format(a)
'(a, 1)'
>>> '({}, {})'.format(*a)
'(a, 1)'
>>> '{0[0]}, {0[1]}'.format(a) # without parentheses
'a, 1'
>>> '{}, {}'.format(*a) # without parentheses
'a, 1'
Upvotes: 2