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

Re: How to test input via subprocess.Popen with data from file

2022-03-11 Thread Tobiah
Why not just have scripts that echo out the various sets of test data you are interested in? That way, Popen would always be your interface and you wouldn't have to make two cases in the consumer script. In other words, make program that outputs test data just like your main data source program.

Re: How to test input via subprocess.Popen with data from file

2022-03-11 Thread Roel Schroeven
Op 11/03/2022 om 10:11 schreef Roel Schroeven: Op 10/03/2022 om 13:16 schreef Loris Bennett: Hi, I have a command which produces output like the following:    Job ID: 9431211    Cluster: curta    User/Group: build/staff    State: COMPLETED (exit code 0)    Nodes: 1    Cores per node: 8    CPU

Re: How to test input via subprocess.Popen with data from file

2022-03-11 Thread Roel Schroeven
Op 10/03/2022 om 13:16 schreef Loris Bennett: Hi, I have a command which produces output like the following: Job ID: 9431211 Cluster: curta User/Group: build/staff State: COMPLETED (exit code 0) Nodes: 1 Cores per node: 8 CPU Utilized: 01:30:53 CPU Efficiency: 83.63% of

Re: How to test input via subprocess.Popen with data from file

2022-03-10 Thread Dieter Maurer
Loris Bennett wrote at 2022-3-11 07:40 +0100: > ... I want to test the parsing ... >Sorry if I was unclear but my question is: > >Given that the return value from Popen is a Popen object and given that >the return value from reading a file is a single string or maybe a list >of strings, what should

Re: How to test input via subprocess.Popen with data from file

2022-03-10 Thread Loris Bennett
Dieter Maurer writes: > Loris Bennett wrote at 2022-3-10 13:16 +0100: >>I have a command which produces output like the >>following: >> >> Job ID: 9431211 >> Cluster: curta >> User/Group: build/staff >> State: COMPLETED (exit code 0) >> Nodes: 1 >> Cores per node: 8 >> CPU Utilized: 01:30:

Re: How to test input via subprocess.Popen with data from file

2022-03-10 Thread Dieter Maurer
Loris Bennett wrote at 2022-3-10 13:16 +0100: >I have a command which produces output like the >following: > > Job ID: 9431211 > Cluster: curta > User/Group: build/staff > State: COMPLETED (exit code 0) > Nodes: 1 > Cores per node: 8 > CPU Utilized: 01:30:53 > CPU Efficiency: 83.63% of 01:4

Re: How to test for maildir 'folder' in Python?

2022-01-23 Thread Barry
> On 23 Jan 2022, at 17:08, Chris Green wrote: > > Barry Scott wrote: >> >> On 22 Jan 2022, at 21:26, Chris Green wrote: >>> >>> I have a script that walks a quite deep tree of mail messages to find >>> and archive old messages. I'm trying to convert it from mbox to >>> maildir (as

Re: How to test for maildir 'folder' in Python?

2022-01-23 Thread Chris Green
Barry Scott wrote: > > > > On 22 Jan 2022, at 21:26, Chris Green wrote: > > > > I have a script that walks a quite deep tree of mail messages to find > > and archive old messages. I'm trying to convert it from mbox to > > maildir (as I now store my mail in maildir format). > > > > So I need

Re: How to test for maildir 'folder' in Python?

2022-01-23 Thread Chris Green
Cameron Simpson wrote: > On 22Jan2022 21:26, Chris Green wrote: > >So I need to test whether a point I have reached in the hierarchy is a > >maildir mailbox or not. Using mbox format it's easy because 'folders' > >are directories and mailboxes are files. However with maildir the > >'folders' ha

Re: How to test for maildir 'folder' in Python?

2022-01-23 Thread Barry Scott
> On 22 Jan 2022, at 21:26, Chris Green wrote: > > I have a script that walks a quite deep tree of mail messages to find > and archive old messages. I'm trying to convert it from mbox to > maildir (as I now store my mail in maildir format). > > So I need to test whether a point I have reached

Re: How to test for maildir 'folder' in Python?

2022-01-22 Thread Cameron Simpson
On 22Jan2022 21:26, Chris Green wrote: >So I need to test whether a point I have reached in the hierarchy is a >maildir mailbox or not. Using mbox format it's easy because 'folders' >are directories and mailboxes are files. However with maildir the >'folders' have directories within them so the

Re: How to test?

2020-06-21 Thread Manfred Lotz
On Wed, 17 Jun 2020 17:34:55 +0100 Tony Flury wrote: > On 24/04/2020 19:40, Manfred Lotz wrote: > > I have a command like application which checks a directory tree for > > certain things. If there are errors then messages will be written to > > stdout. > > > > How to test this in the best way? >

Re: How to test?

2020-06-20 Thread Mats Wichmann
On 5/1/20 2:34 PM, DL Neil via Python-list wrote: >>> Given your replies, 'now' might be a good time to take a look at >>> Pytest, and see how you could use it to help build better code - by >>> building tested units/functions which are assembled into ever-larger >>> tested-units... (there is a ran

Re: How to test?

2020-06-20 Thread Stephen Rosen
Worth noting: by assertTrue he probably meant assertEqual. But I'd recommend using assertIn [1] if you're using unittest to check output written to stdout/stderr. That way, your tests are slightly more robust to changes in the exact output. pytest may also be helpful for this (or any!) type of te

Re: How to test?

2020-06-19 Thread Terry Reedy
On 6/17/2020 12:34 PM, Tony Flury via Python-list wrote: In a recent application that I wrote (where output to the console was important), I tested it using the 'unittest' framework, and by patching sys.stderr to be a StringIO - that way my test case could inspect what was being output. Tony

Re: How to test?

2020-06-19 Thread Tony Flury via Python-list
On 24/04/2020 19:40, Manfred Lotz wrote: I have a command like application which checks a directory tree for certain things. If there are errors then messages will be written to stdout. How to test this in the best way? One idea was for the error situations to write messages to files and then

Re: How to test?

2020-05-01 Thread DL Neil via Python-list
Given your replies, 'now' might be a good time to take a look at Pytest, and see how you could use it to help build better code - by building tested units/functions which are assembled into ever-larger tested-units... (there is a range of choice/other testing aids if Pytest doesn't take your fancy

Re: How to test?

2020-04-30 Thread Manfred Lotz
On Mon, 27 Apr 2020 18:21:39 +1200 DL Neil wrote: ... > > Given your replies, 'now' might be a good time to take a look at > Pytest, and see how you could use it to help build better code - by > building tested units/functions which are assembled into ever-larger > tested-units... (there is a r

Re: How to test?

2020-04-26 Thread DL Neil via Python-list
If I have understood correctly, the objective is to check a dir-tree to ensure that specific directory/file-permissions are in-effect/have not been changed. The specifications come from a .JSON file and may be over-ridden by command-line arguments. Correct? Yes. How to test this in the best

Re: How to test?

2020-04-26 Thread Manfred Lotz
On Sun, 26 Apr 2020 15:26:58 +1200 DL Neil wrote: > On 25/04/20 7:53 PM, Manfred Lotz wrote: > > On Sat, 25 Apr 2020 18:41:37 +1200 > > DL Neil wrote: > > > >> On 25/04/20 5:16 PM, Manfred Lotz wrote: > >>> On Fri, 24 Apr 2020 19:12:39 -0300 > >>> Cholo Lennon wrote: > >>> > On

Re: How to test?

2020-04-25 Thread DL Neil via Python-list
On 25/04/20 7:53 PM, Manfred Lotz wrote: On Sat, 25 Apr 2020 18:41:37 +1200 DL Neil wrote: On 25/04/20 5:16 PM, Manfred Lotz wrote: On Fri, 24 Apr 2020 19:12:39 -0300 Cholo Lennon wrote: On 24/4/20 15:40, Manfred Lotz wrote: I have a command like application which checks a directory tr

Re: How to test?

2020-04-25 Thread Cholo Lennon
On 4/25/20 2:16 AM, Manfred Lotz wrote: On Fri, 24 Apr 2020 19:12:39 -0300 Cholo Lennon wrote: On 24/4/20 15:40, Manfred Lotz wrote: I have a command like application which checks a directory tree for certain things. If there are errors then messages will be written to stdout. How to test th

Re: How to test?

2020-04-25 Thread Manfred Lotz
On Sat, 25 Apr 2020 18:41:37 +1200 DL Neil wrote: > On 25/04/20 5:16 PM, Manfred Lotz wrote: > > On Fri, 24 Apr 2020 19:12:39 -0300 > > Cholo Lennon wrote: > > > >> On 24/4/20 15:40, Manfred Lotz wrote: > >>> I have a command like application which checks a directory tree > >>> for certain

Re: How to test?

2020-04-24 Thread DL Neil via Python-list
On 25/04/20 5:16 PM, Manfred Lotz wrote: On Fri, 24 Apr 2020 19:12:39 -0300 Cholo Lennon wrote: On 24/4/20 15:40, Manfred Lotz wrote: I have a command like application which checks a directory tree for certain things. If there are errors then messages will be written to stdout. How to test t

Re: How to test?

2020-04-24 Thread Manfred Lotz
On 24 Apr 2020 22:18:45 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: > DL Neil writes: > >Python's logging library enables messages to be formatted > >accordingly, and directed differently, depending upon 'level of > >severity'. So, as well as the flexibility mentioned before, there is > >an o

Re: How to test?

2020-04-24 Thread Manfred Lotz
On Fri, 24 Apr 2020 19:12:39 -0300 Cholo Lennon wrote: > On 24/4/20 15:40, Manfred Lotz wrote: > > I have a command like application which checks a directory tree for > > certain things. If there are errors then messages will be written to > > stdout. > > > > How to test this in the best way? >

Re: How to test?

2020-04-24 Thread Cholo Lennon
On 24/4/20 15:40, Manfred Lotz wrote: I have a command like application which checks a directory tree for certain things. If there are errors then messages will be written to stdout. How to test this in the best way? One idea was for the error situations to write messages to files and then late

Re: How to test?

2020-04-24 Thread DL Neil via Python-list
May I point-out that the above may not be the best approach. Rather than using screen-prints to report errors, another method is to utilise "logging" to collect such data - so that there is always a formal record (regardless of user behavior). During 'production' the information could be collected

Re: How to test?

2020-04-24 Thread Manfred Lotz
On Sat, 25 Apr 2020 08:25:00 +1200 DL Neil wrote: > On 25/04/20 6:40 AM, Manfred Lotz wrote: > > I have a command like application which checks a directory tree for > > certain things. If there are errors then messages will be written to > > stdout. > > > > How to test this in the best way? > >

Re: How to test?

2020-04-24 Thread Manfred Lotz
On 24 Apr 2020 20:17:04 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: > Manfred Lotz writes: > >I have a command like application which checks a directory tree for > >certain things. If there are errors then messages will be written to > >stdout. > > Error messages should be written to sys

Re: How to test?

2020-04-24 Thread DL Neil via Python-list
On 25/04/20 6:40 AM, Manfred Lotz wrote: I have a command like application which checks a directory tree for certain things. If there are errors then messages will be written to stdout. How to test this in the best way? One idea was for the error situations to write messages to files and then l

Re: How to test the data type of a variable

2020-04-23 Thread Souvik Dutta
He is talking about this. https://mail.python.org/mailman/listinfo/python-list Scroll down to the bottom of the page and you will find overview of all.. Souvik flutter dev On Fri, Apr 24, 2020, 7:50 AM Deac-33 Lancaster wrote: > On Thursday, April 23, 2020 at 7:14:16 PM UTC-7, DL Neil wrote

Re: How to test the data type of a variable

2020-04-23 Thread Deac-33 Lancaster
On Thursday, April 23, 2020 at 7:14:16 PM UTC-7, DL Neil wrote: > ... Is there a way to see all of the groups? > > Yes! Follow the link at the bottom of this email msg. Then follow the > link at the bottom of this list's web-page ... > -- > Regards =dn Sorry, I don't see the link. -deac33 -- h

Re: How to test the data type of a variable

2020-04-23 Thread DL Neil via Python-list
... Is there a way to see all of the groups? Yes! Follow the link at the bottom of this email msg. Then follow the link at the bottom of this list's web-page ... -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list

Re: How to test the data type of a variable

2020-04-23 Thread Deac-33 Lancaster
On Thursday, April 23, 2020 at 7:11:47 PM UTC-7, DL Neil wrote: > On 24/04/20 1:24 PM, Deac-33 Lancaster wrote: > > I'm aware that you can find the type of a variable with > > type(var) > > > > But are there Boolean operators in Python3.8 to test the data type, e.g. > >is_floate(var) > >

Re: How to test the data type of a variable

2020-04-23 Thread DL Neil via Python-list
On 24/04/20 1:24 PM, Deac-33 Lancaster wrote: I'm aware that you can find the type of a variable with type(var) But are there Boolean operators in Python3.8 to test the data type, e.g. is_floate(var) is_string(var) etc. ? There is also a 'pythonic' answer (what is the 'Python way'?)

Re: How to test the data type of a variable

2020-04-23 Thread Deac-33 Lancaster
On Thursday, April 23, 2020 at 6:47:04 PM UTC-7, DL Neil wrote: > On 24/04/20 1:24 PM, Deac-33 Lancaster wrote: > > I'm aware that you can find the type of a variable with > > type(var) > > > > But are there Boolean operators in Python3.8 to test the data type, e.g. > >is_floate(var) > >

Re: How to test the data type of a variable

2020-04-23 Thread Deac-33 Lancaster
On Thursday, April 23, 2020 at 6:46:14 PM UTC-7, Alan Bawden wrote: > Deac-33 Lancaster writes: > > > I'm aware that you can find the type of a variable with > >type(var) > > (Strictly speaking, variables don't have types. This gives you the type of > the variable's current value. But we

Re: How to test the data type of a variable

2020-04-23 Thread Alan Bawden
Deac-33 Lancaster writes: > I'm aware that you can find the type of a variable with >type(var) (Strictly speaking, variables don't have types. This gives you the type of the variable's current value. But we know what you meant.) > But are there Boolean operators in Python3.8 to test the

Re: How to test the data type of a variable

2020-04-23 Thread Deac-33 Lancaster
ChrisA, Most awesome, thank you very much, I just couldn't find that in the docs. Still learning! Much thanks, -deac33 -- https://mail.python.org/mailman/listinfo/python-list

Re: How to test the data type of a variable

2020-04-23 Thread DL Neil via Python-list
On 24/04/20 1:24 PM, Deac-33 Lancaster wrote: I'm aware that you can find the type of a variable with type(var) But are there Boolean operators in Python3.8 to test the data type, e.g. is_floate(var) is_string(var) etc. ? You are close! https://docs.python.org/3/library/functions.htm

Re: How to test the data type of a variable

2020-04-23 Thread Chris Angelico
On Fri, Apr 24, 2020 at 11:26 AM Deac-33 Lancaster wrote: > > I'm aware that you can find the type of a variable with >type(var) > > But are there Boolean operators in Python3.8 to test the data type, e.g. > is_floate(var) > is_string(var) > etc. ? > > (If this is the wrong group for this

Re: How to test for type or instance of dict_values?

2018-12-11 Thread fabian . becker87
Very late to the party, but I just encountered a very similar problem and found a solution: ``` import collections obj = {"foo": "bar"} isinstance(obj.values(), collections.abc.ValuesView) # => True ``` Hope that helps someone out there :) On Thursday, November 17, 2016 at 9:09:23 AM UTC-8, Te

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Terry Reedy
On 11/17/2016 9:57 AM, Thorsten Kampe wrote: The code in question is part of an attempt to get the dimensions of multi-dimensional lists, the `isinstance` is there in order to exclude strings. You can do the exclusion directly. """ def dim(seq): dimension = [] while isinstance(seq,

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Thorsten Kampe
* Peter Otten (Thu, 17 Nov 2016 13:38:26 +0100) > > Thorsten Kampe wrote: > > > How can I test for type or instance of dictviews like dict_values? > > Why do you want to? Thanks, for the `collections.abc.ValuesView` tip. The code in question is part of an attempt to get the dimensions of mult

Re: How to test for type or instance of dict_values?

2016-11-17 Thread Peter Otten
Thorsten Kampe wrote: > How can I test for type or instance of dictviews like dict_values? Why do you want to? > `isinstance({}.values, dict_values)` gives > `NameError: name 'dict_values' is not defined` You can "fix" this with >>> dict_values = type({}.values()) or, depending on the use ca

Re: how to test attribute existence of feedparser objects

2011-12-10 Thread Steven D'Aprano
On Sat, 10 Dec 2011 09:19:31 -0800, xDog Walker wrote: > Use standard Python dictionary functions such as has_key to test whether > an element exists. Idiomatic Python code today no longer uses has_key. # Was: d.feed.has_key('title') # Now preferred 'title' in d.feed -- Steven -- http://ma

Re: how to test attribute existence of feedparser objects

2011-12-10 Thread xDog Walker
On Thursday 2011 December 08 01:34, HansPeter wrote: > Hi, > > While using the feedparser library for downloading RSS feeds some of > the blog entries seem to have no title. > > File "build\bdist.win32\egg\feedparser.py", line 382, in __getattr__ > AttributeError: object has no attribute 'title' >

Re: how to test attribute existence of feedparser objects

2011-12-08 Thread Chris Rebert
On Thu, Dec 8, 2011 at 1:34 AM, HansPeter wrote: > Hi, > > While using the feedparser library for downloading RSS feeds some of > the blog entries seem to have no title. > >  File "build\bdist.win32\egg\feedparser.py", line 382, in __getattr__ > AttributeError: object has no attribute 'title' > >

Re: How to test if object is an integer?

2011-10-17 Thread Steven D'Aprano
On Mon, 17 Oct 2011 18:59:44 -0600, Ian Kelly wrote: > On Mon, Oct 17, 2011 at 6:40 PM, Chris Kaynor > wrote: >> Python 2.6 running on Windows 7: > 99.0**99**99 >> OverflowError: (34, 'Result too large') Traceback (most recent call >> last): >>   File "", line 1, in >> OverflowError: (34, 'R

Re: How to test if object is an integer?

2011-10-17 Thread Yingjie Lan
- Original Message - > From: Noah Hall > To: MrPink > Cc: python-list@python.org > Sent: Tuesday, October 18, 2011 4:44 AM > Subject: Re: How to test if object is an integer? > There's the isdigit method, for example - > >>>> str = "13

Re: How to test if object is an integer?

2011-10-17 Thread Ian Kelly
On Mon, Oct 17, 2011 at 6:40 PM, Chris Kaynor wrote: > Python 2.6 running on Windows 7: 99.0**99**99 > OverflowError: (34, 'Result too large') > Traceback (most recent call last): >   File "", line 1, in > OverflowError: (34, 'Result too large') > > However, from the documentation: > "Becaus

Re: How to test if object is an integer?

2011-10-17 Thread Chris Kaynor
Python 2.6 running on Windows 7: >>> 99.0**99**99 OverflowError: (34, 'Result too large') Traceback (most recent call last):   File "", line 1, in OverflowError: (34, 'Result too large') However, from the documentation: "Because of the lack of standardization of floating point exception handling

Re: How to test if object is an integer?

2011-10-17 Thread Roy Smith
In article , Mathias Lafeldt wrote: > According to [1], there're more Exceptions to test for: > > try: > int(s) > return True > except (TypeError, ValueError, OverflowError): # int conversion failed > return False I don't think I would catch TypeError here. It kind of depends on

Re: How to test if object is an integer?

2011-10-17 Thread Ian Kelly
On Mon, Oct 17, 2011 at 2:44 PM, Noah Hall wrote: > There's the isdigit method, for example - > str = "1324325" str.isdigit() > True str = "1232.34" str.isdigit() > False str = "I am a string, not an int!" str.isdigit() > False That works for non-negative base-10 int

Re: How to test if object is an integer?

2011-10-17 Thread Noah Hall
On Sat, Oct 15, 2011 at 12:44 AM, MrPink wrote: > > Is there a function in Python that can be used to test if the value in > a string is an integer?  I had to make one up for myself and it looks > like this: > > def isInt(s): >    try: >        i = int(s) >        return True >    except ValueErro

Re: How to test if object is an integer?

2011-10-17 Thread Mathias Lafeldt
On Sat, Oct 15, 2011 at 1:44 AM, MrPink wrote: > > Is there a function in Python that can be used to test if the value in > a string is an integer?  I had to make one up for myself and it looks > like this: > > def isInt(s): >    try: >        i = int(s) >        return True >    except ValueError

Re: How to test if object is an integer?

2011-10-14 Thread Terry Reedy
On 10/14/2011 9:51 PM, Ben Finney wrote: Terry Reedy writes: On 10/14/2011 9:05 PM, Chris Angelico wrote: That tests if the object is already an int; the OP asked if a string contains an integer. The misleading subject line did not. It should have been "How to test if a string contains an

Re: How to test if object is an integer?

2011-10-14 Thread Ben Finney
Terry Reedy writes: > On 10/14/2011 9:05 PM, Chris Angelico wrote: > > That tests if the object is already an int; the OP asked if a string > > contains an integer. > > The misleading subject line did not. It should have been "How to test > if a string contains an integer?" Which would still be

  1   2   3   >