Re: best way to remove leading zeros from a tuple like string
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
Re: best way to remove leading zeros from a tuple like string
On Wed, May 23, 2018 at 12:50 AM, Grant Edwardswrote: > 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
Re: best way to remove leading zeros from a tuple like string
On 2018-05-22, Thomas Jollanswrote: > 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
Re: best way to remove leading zeros from a tuple like string
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
Re: best way to remove leading zeros from a tuple like string
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? --
Re: best way to remove leading zeros from a tuple like string
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,
Re: best way to remove leading zeros from a tuple like string
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
Re: best way to remove leading zeros from a tuple like string
>>> 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,
Re: best way to remove leading zeros from a tuple like string
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
Re: best way to remove leading zeros from a tuple like string
On Sunday, May 20, 2018 at 6:56:05 PM UTC-4, Ben Bacarisse wrote: > "Michael F. Stemper"writes: > > > On 2018-05-20 16:19, Ben Bacarisse wrote: > >> bruceg113...@gmail.com writes: > >> > >>> Lets say I have the following tuple like string. > >>>(128, 020,
Re: best way to remove leading zeros from a tuple like string
"Michael F. Stemper"writes: > On 2018-05-20 16:19, Ben Bacarisse wrote: >> bruceg113...@gmail.com writes: >> >>> 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
Re: best way to remove leading zeros from a tuple like string
On 2018-05-20 16:19, Ben Bacarisse wrote:bruceg113...@gmail.com writes:Re: best way to remove leading zeros from a tuple like stringbruceg113...@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 >
Re: best way to remove leading zeros from a tuple like string
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
Re: best way to remove leading zeros from a tuple like string
On Sun, May 20, 2018, 5:53 PM Paulwrote: > 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
Re: best way to remove leading zeros from a tuple like string
> > > This works for me: mytuplestring.replace("0","") > > Your regex will also eliminate non-leading zeros. -- https://mail.python.org/mailman/listinfo/python-list
Re: best way to remove leading zeros from a tuple like string
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.
Re: best way to remove leading zeros from a tuple like string
bruceg113...@gmail.com writes: > 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 You could use a regexp: import re
Re: best way to remove leading zeros from a tuple like string
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