Re: How to test characters of a string

2022-06-09 Thread Christian Gollwitzer
Am 08.06.22 um 19:57 schrieb De ongekruisigde: On 2022-06-08, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: On 2022-06-09 at 04:15:46 +1000, Chris Angelico wrote: If you insist: >>> s = 'nm-iodine:x:996:57::/var/empty:/run/current-system/sw/bin/nologin'

Re: How to test characters of a string

2022-06-09 Thread Christian Gollwitzer
Am 09.06.22 um 07:50 schrieb Dave: Hi, I’ve found you also need to take care of multiple disk CD releases. These have a format of “1-01 Track Name” “2-02 Trackl Name" Meaning Disk 1 Track1, Disk 2, Track 2. Also A and B Sides (from Vinyl LPs) “A1-Track Name” “B2-Track Name” Side A, Track

Re: How to test characters of a string

2022-06-09 Thread Avi Gross via Python-list
2022 2:50 am Subject: Re: How to test characters of a string Hi, I’ve found you also need to take care of multiple disk CD releases. These have a format of “1-01 Track Name” “2-02  Trackl Name" Meaning Disk 1 Track1, Disk 2, Track 2. Also A and B Sides (from Vinyl LPs) “A1-Track Name” “B

Re: How to test characters of a string

2022-06-08 Thread Dave
Hi, I’ve found you also need to take care of multiple disk CD releases. These have a format of “1-01 Track Name” “2-02 Trackl Name" Meaning Disk 1 Track1, Disk 2, Track 2. Also A and B Sides (from Vinyl LPs) “A1-Track Name” “B2-Track Name” Side A, Track 1, etc. Cheers Dave > On 8 Jun 202

Re: How to test characters of a string

2022-06-08 Thread De ongekruisigde
On 2022-06-08, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2022-06-09 at 04:15:46 +1000, > Chris Angelico wrote: > >> On Thu, 9 Jun 2022 at 04:14, <2qdxy4rzwzuui...@potatochowder.com> wrote: >> > >> > On 2022-06-09 at 03:18:56 +1000, >> > Chris Angelico wr

Re: How to test characters of a string

2022-06-08 Thread Dennis Lee Bieber
On Wed, 8 Jun 2022 01:53:26 + (UTC), Avi Gross declaimed the following: > >So is it necessary to insist on an exact pattern of two digits followed by a >space?  > > >That would fail on "44 Minutes", "40 Oz. Dream", "50 Mission Cap", "50 Ways to >Say Goodbye", "99 Ways to Die"  > >It looks

Re: How to test characters of a string

2022-06-08 Thread De ongekruisigde
On 2022-06-08, 2qdxy4rzwzuui...@potatochowder.com <2qdxy4rzwzuui...@potatochowder.com> wrote: > On 2022-06-08 at 08:07:40 -, > De ongekruisigde wrote: > >> Depending on the problem a regular expression may be the much simpler >> solution. I love them for e.g. text parsing and use them all the

Re: How to test characters of a string

2022-06-08 Thread 2QdxY4RzWzUUiLuE
On 2022-06-09 at 04:15:46 +1000, Chris Angelico wrote: > On Thu, 9 Jun 2022 at 04:14, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > On 2022-06-09 at 03:18:56 +1000, > > Chris Angelico wrote: > > > > > On Thu, 9 Jun 2022 at 03:15, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > > > > >

Re: How to test characters of a string

2022-06-08 Thread Chris Angelico
On Thu, 9 Jun 2022 at 04:14, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-06-09 at 03:18:56 +1000, > Chris Angelico wrote: > > > On Thu, 9 Jun 2022 at 03:15, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > > > On 2022-06-08 at 08:07:40 -, > > > De ongekruisigde wrote: > > > > >

Re: How to test characters of a string

2022-06-08 Thread 2QdxY4RzWzUUiLuE
On 2022-06-09 at 03:18:56 +1000, Chris Angelico wrote: > On Thu, 9 Jun 2022 at 03:15, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > On 2022-06-08 at 08:07:40 -, > > De ongekruisigde wrote: > > > > > Depending on the problem a regular expression may be the much simpler > > > solution. I

Re: How to test characters of a string

2022-06-08 Thread Chris Angelico
On Thu, 9 Jun 2022 at 03:15, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2022-06-08 at 08:07:40 -, > De ongekruisigde wrote: > > > Depending on the problem a regular expression may be the much simpler > > solution. I love them for e.g. text parsing and use them all the time. > > Unrival

Re: How to test characters of a string

2022-06-08 Thread 2QdxY4RzWzUUiLuE
On 2022-06-08 at 08:07:40 -, De ongekruisigde wrote: > Depending on the problem a regular expression may be the much simpler > solution. I love them for e.g. text parsing and use them all the time. > Unrivaled when e.g. parts of text have to be extracted, e.g. from lines > like these: > >

Re: How to test characters of a string

2022-06-08 Thread Barry Scott
> On 7 Jun 2022, at 23:24, Dave wrote: > > Yes, it was probably just a typeo on my part. > > I’ve now fixed the majority of cases but still got two strings that look > identical but fail to match, this time (again by 10cc), “I’m Mandy Fly Me”. > > I’m putting money on it being a utf8 problem

Re: How to test characters of a string

2022-06-08 Thread De ongekruisigde
On 2022-06-08, Christian Gollwitzer wrote: > Am 07.06.22 um 23:01 schrieb Christian Gollwitzer: > >>> In [3]: re.sub(r'^\d+\s*', '', s) Out[3]: 'Trinket' >>> > > that RE does match what you intended to do, but not exactly what you > wrote in the OP. that would be '^\d\d.' start with exactly two

Re: How to test characters of a string

2022-06-08 Thread De ongekruisigde
On 2022-06-08, Dave wrote: > I hate regEx and avoid it whenever possible, I’ve never found something that > was impossible to do without it. I love regular expressions and use them where appropriate. Saves tons of code and is often much more readable than the pages of code required to do the sam

Re: How to test characters of a string

2022-06-08 Thread De ongekruisigde
On 2022-06-08, dn wrote: > On 08/06/2022 10.18, De ongekruisigde wrote: >> On 2022-06-08, Christian Gollwitzer wrote: >>> Am 07.06.22 um 21:56 schrieb Dave: It depends on the language I’m using, in Objective C, I’d use isNumeric, just wanted to know what the equivalent is in Python. >>

Re: How to test characters of a string

2022-06-07 Thread Avi Gross via Python-list
the original (perhaps with some normalization of case and whitespace, fine. If not will they match if one or both have something to remove as a prefix such as "02 ". And if you are comparing items where the same song is in two different numeric sequences on different disks, ...

Re: How to test characters of a string

2022-06-07 Thread MRAB
On 2022-06-07 23:24, Dave wrote: Yes, it was probably just a typeo on my part. You've misspelled "typo"! I’ve now fixed the majority of cases but still got two strings that look identical but fail to match, this time (again by 10cc), “I’m Mandy Fly Me”. Try printing the asciified string:

Re: How to test characters of a string

2022-06-07 Thread Dave
I hate regEx and avoid it whenever possible, I’ve never found something that was impossible to do without it. > On 8 Jun 2022, at 00:49, dn wrote: > > On 08/06/2022 10.18, De ongekruisigde wrote: >> On 2022-06-08, Christian Gollwitzer wrote: >>> Am 07.06.22 um 21:56 schrieb Dave: It depen

Re: How to test characters of a string

2022-06-07 Thread dn
On 08/06/2022 10.18, De ongekruisigde wrote: > On 2022-06-08, Christian Gollwitzer wrote: >> Am 07.06.22 um 21:56 schrieb Dave: >>> It depends on the language I’m using, in Objective C, I’d use isNumeric, >>> just wanted to know what the equivalent is in Python. >>> >> >> Your problem is also a t

Re: How to test characters of a string

2022-06-07 Thread Dave
rotfl! Nice one! > On 8 Jun 2022, at 00:24, 2qdxy4rzwzuui...@potatochowder.com wrote: > > On 2022-06-07 at 23:07:42 +0100, > Regarding "Re: How to test characters of a string," > MRAB wrote: > >> On 2022-06-07 21:23, Dave wrote: >>> Thanks a

Re: How to test characters of a string

2022-06-07 Thread Dave
Yes, it was probably just a typeo on my part. I’ve now fixed the majority of cases but still got two strings that look identical but fail to match, this time (again by 10cc), “I’m Mandy Fly Me”. I’m putting money on it being a utf8 problem but I’m stuck on how to handle it. It’s probably the si

Re: How to test characters of a string

2022-06-07 Thread dn
It depends on the language I’m using, in Objective C, I’d use isNumeric, just wanted to know what the equivalent is in Python. If you know the answer why don’t you just tell me and if you don’t, don’t post! >>> >>> People ask home work questions here and we try to teach

Re: How to test characters of a string

2022-06-07 Thread De ongekruisigde
On 2022-06-08, Christian Gollwitzer wrote: > Am 07.06.22 um 21:56 schrieb Dave: >> It depends on the language I’m using, in Objective C, I’d use isNumeric, >> just wanted to know what the equivalent is in Python. >> > > Your problem is also a typical case for regular expressions. You can > crea

Re: How to test characters of a string

2022-06-07 Thread Christian Gollwitzer
Am 07.06.22 um 23:01 schrieb Christian Gollwitzer: In [3]: re.sub(r'^\d+\s*', '', s) Out[3]: 'Trinket' that RE does match what you intended to do, but not exactly what you wrote in the OP. that would be '^\d\d.' start with exactly two digits followed by any character. Christian -

Re: How to test characters of a string

2022-06-07 Thread Christian Gollwitzer
Am 07.06.22 um 21:56 schrieb Dave: It depends on the language I’m using, in Objective C, I’d use isNumeric, just wanted to know what the equivalent is in Python. Your problem is also a typical case for regular expressions. You can create an expression for "starts with any number of digits pl

Re: How to test characters of a string

2022-06-07 Thread 2QdxY4RzWzUUiLuE
On 2022-06-07 at 23:07:42 +0100, Regarding "Re: How to test characters of a string," MRAB wrote: > On 2022-06-07 21:23, Dave wrote: > > Thanks a lot for this! isDigit was the method I was looking for and > > couldn’t find. > > > > I have another problem rel

Re: How to test characters of a string

2022-06-07 Thread MRAB
On 2022-06-07 21:23, Dave wrote: Thanks a lot for this! isDigit was the method I was looking for and couldn’t find. I have another problem related to this, the following code uses the code you just sent. I am getting a files ID3 tags using eyed3, this part seems to work and I get expected val

Re: How to test characters of a string

2022-06-07 Thread 2QdxY4RzWzUUiLuE
On 2022-06-08 at 07:29:03 +1000, Chris Angelico wrote: > On Wed, 8 Jun 2022 at 07:24, Barry wrote: > > > > > > > > > On 7 Jun 2022, at 22:04, Dave wrote: > > > > > > It depends on the language I’m using, in Objective C, I’d use isNumeric, > > > just wanted to know what the equivalent is in Py

Re: How to test characters of a string

2022-06-07 Thread Dave
A, ok will do, was just trying to be a brief as possible, will post more fully in future. > On 7 Jun 2022, at 23:29, Chris Angelico wrote: > > On Wed, 8 Jun 2022 at 07:24, Barry wrote: >> >> >> >>> On 7 Jun 2022, at 22:04, Dave wrote: >>> >>> It depends on the language I’m using, in

Re: How to test characters of a string

2022-06-07 Thread Chris Angelico
On Wed, 8 Jun 2022 at 07:24, Barry wrote: > > > > > On 7 Jun 2022, at 22:04, Dave wrote: > > > > It depends on the language I’m using, in Objective C, I’d use isNumeric, > > just wanted to know what the equivalent is in Python. > > > > If you know the answer why don’t you just tell me and if yo

Re: How to test characters of a string

2022-06-07 Thread Barry
> On 7 Jun 2022, at 22:04, Dave wrote: > > It depends on the language I’m using, in Objective C, I’d use isNumeric, > just wanted to know what the equivalent is in Python. > > If you know the answer why don’t you just tell me and if you don’t, don’t > post! People ask home work questions h

Re: How to test characters of a string

2022-06-07 Thread Dave
Hi, Found it! The files name had .mp3 at the end, the problem was being masked by null objects (or whatever) being returned by eyed3. Checked for null objects and then stripped off the .mp3 and its mostly working now. I’ve got a few other eyed3 errors to do with null objects but I can sort tho

Re: How to test characters of a string

2022-06-07 Thread Dave
Hi, No, I’ve checked leading/trailing whitespace, it seems to be related to the variables that are returned from eyed3 in this case, for instance, I added a check for None: myTitleName = myID3.tag.title if myTitleName is None: continue Seems like it can return a null object (or none?). >

Re: How to test characters of a string

2022-06-07 Thread Dave
It depends on the language I’m using, in Objective C, I’d use isNumeric, just wanted to know what the equivalent is in Python. If you know the answer why don’t you just tell me and if you don’t, don’t post! > On 7 Jun 2022, at 22:08, 2qdxy4rzwzuui...@potatochowder.com wrote: > > On 2022-06-07

Re: How to test characters of a string

2022-06-07 Thread De ongekruisigde
On 2022-06-07, Dave wrote: > Thanks a lot for this! isDigit was the method I was looking for and couldn’t > find. > > I have another problem related to this, the following code uses the code you > just sent. I am getting a files ID3 tags using eyed3, this part seems to work > and I get expected

Re: How to test characters of a string

2022-06-07 Thread De ongekruisigde
On 2022-06-07, Stefan Ram wrote: > Dave writes: >>Example: if "05 Trinket" I want "Trinket" > > We're not supposed to write complete solutions, Okay, wasn't aware of this group policy; will keep it in mind. -- You're rewriting parts of Quake in *Python*? MUAHAHAHA -- https://mail.python.

Re: How to test characters of a string

2022-06-07 Thread 2QdxY4RzWzUUiLuE
On 2022-06-07 at 21:35:43 +0200, Dave wrote: > I’m new to Python and have a simple problem that I can’t seem to find > the answer. > I want to test the first two characters of a string to check if the > are numeric (00 to 99) and if so remove the fist three chars from the > string. > Example: i

Re: How to test characters of a string

2022-06-07 Thread Dave
Thanks a lot for this! isDigit was the method I was looking for and couldn’t find. I have another problem related to this, the following code uses the code you just sent. I am getting a files ID3 tags using eyed3, this part seems to work and I get expected values in this case myTitleName (Track

Re: How to test characters of a string

2022-06-07 Thread De ongekruisigde
On 2022-06-07, Dave wrote: > Hi, > > I’m new to Python and have a simple problem that I can’t seem to find the > answer. > > I want to test the first two characters of a string to check if the are > numeric (00 to 99) and if so remove the fist three chars from the string. > > Example: if “05 Tr

Re: How to test characters of a string

2022-06-07 Thread dn
On 08/06/2022 07.35, Dave wrote: > Hi, > > I’m new to Python and have a simple problem that I can’t seem to find the > answer. > I want to test the first two characters of a string to check if the are > numeric (00 to 99) and if so remove the fist three chars from the string. > > Example: if