On Sun, May 20, 2018 at 12:54 PM, wrote:
> Lets say I have the following tuple like string.
> (128, 020, 008, 255)
>
> What is the best way to to remove leading zeroes and end up with the
> following.
> (128, 20, 8, 255)-- I do not care about spaces
>
> This is the solution I came up
On Wed, May 23, 2018 at 12:50 AM, Grant Edwards
wrote:
> On 2018-05-22, Thomas Jollans wrote:
>> On 2018-05-20 23:54, Paul wrote:
>>> you will find several useful sites where you can test regexes. Regex
>>> errors are very common, even after you have experience with them.
>>
>> What's the benefi
On 2018-05-22, Thomas Jollans wrote:
> On 2018-05-20 23:54, Paul wrote:
>> you will find several useful sites where you can test regexes. Regex
>> errors are very common, even after you have experience with them.
>
> What's the benefit of those compared to simply trying out the regex in a
> Pytho
Thomas Jollans wrote:
> On 2018-05-20 23:54, Paul wrote:
> > you will find several useful sites where you can test regexes.
>
> What's the benefit of those compared to simply trying out the regex in a
> Python console?
>
Possibly nothing. But there are obvious benefits compared to trying to
writ
On 2018-05-20 23:54, Paul wrote:
> you will find several useful sites where you can test regexes. Regex
> errors are very common, even after you have experience with them.
What's the benefit of those compared to simply trying out the regex in a
Python console?
--
https://mail.python.org/mailman/
Am 21.05.2018 um 01:16 schrieb bruceg113...@gmail.com:
If I decide I need the parentheses, this works.
"(" + ",".join([str(int(i)) for i in s[1:-1].split(",")]) + ")"
'(128,20,8,255,-1203,1,0,-123)'
Thanks,
Bruce
Creating the tuple seems to be even simpler.
>>> str(tuple(map(int, s[1:-1].s
On Monday, May 21, 2018 at 1:05:52 PM UTC-4, Rodrigo Bistolfi wrote:
> >>> repr(tuple(int(i) for i in s[1:-1].split(',')))
> '(128, 20, 8, 255, -1203, 1, 0, -123)'
>
> 2018-05-21 4:26 GMT-03:00 Peter Otten <__pete...@web.de>:
>
> > bruceg113...@gmail.com wrote:
> >
> > > Looking over the response
>>> repr(tuple(int(i) for i in s[1:-1].split(',')))
'(128, 20, 8, 255, -1203, 1, 0, -123)'
2018-05-21 4:26 GMT-03:00 Peter Otten <__pete...@web.de>:
> bruceg113...@gmail.com wrote:
>
> > Looking over the responses, I modified my original code as follows:
> >
> s = "(128, 020, 008, 255, -
bruceg113...@gmail.com wrote:
> Looking over the responses, I modified my original code as follows:
>
s = "(128, 020, 008, 255, -1203,01,-000, -0123)"
",".join([str(int(i)) for i in s[1:-1].split(",")])
> '128,20,8,255,-1203,1,0,-123'
I think this looks better with a generator inst
bruceg113...@gmail.com wrote:
> Lets say I have the following tuple like string.
> (128, 020, 008, 255)
>
> What is the best way to to remove leading zeroes and end up with the
> following.
> (128, 20, 8, 255)-- I do not care about spaces
>
> This is the solution I came up with
>
On Sunday, May 20, 2018 at 5:32:32 PM UTC-4, Paul wrote:
> >
> >
> > This works for me: mytuplestring.replace("0","")
> >
> > Your regex will also eliminate non-leading zeros.
Your right, what was I thinking?
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, May 20, 2018, 5:53 PM Paul wrote:
> This works for me: mytuplestring.replace("0","")
>
>>
>>> Your regex will also eliminate non-leading zeros.
>>
>>
> If you Google
>
> regex tester
>
> you will find several useful sites where you can test regexes. Regex
> errors are very common, even
>
>
> This works for me: mytuplestring.replace("0","")
>
> Your regex will also eliminate non-leading zeros.
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday, May 20, 2018 at 5:01:08 PM UTC-4, Michael F. Stemper wrote:
> On 2018-05-20 14:54, bruceg113...@gmail.com wrote:
> > Lets say I have the following tuple like string.
> >(128, 020, 008, 255)
> >
> > What is the best way to to remove leading zeroes and end up with the
> > following.
On 2018-05-20 14:54, bruceg113...@gmail.com wrote:
Lets say I have the following tuple like string.
(128, 020, 008, 255)
What is the best way to to remove leading zeroes and end up with the following.
(128, 20, 8, 255)-- I do not care about spaces
I'd use a few regular expressio
Lets say I have the following tuple like string.
(128, 020, 008, 255)
What is the best way to to remove leading zeroes and end up with the following.
(128, 20, 8, 255)-- I do not care about spaces
This is the solution I came up with
s = "(128, 020, 008, 255)"
v = s.replace ("(
16 matches
Mail list logo