Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Listing groups
#1
Suppose I see a line of code like
elif m.group('status').lower() in ['stopped', 'failed']:
And I want to see all statuses that are available.
I tried
logging.warning('m.groups = ' + ' '.join(str(m.group)))
But I get
Output:
TypeError: type object argument after * must be an iterable, not builtin_function_or_method
I have tried several methods, but I always get either the error message above or
Output:
m.groups = < b u i l t - i n m e t h o d g r o u p o f r e . M a t c h o b j e c t a t 0 x 7 f b 2 7 0 a 4 7 1 8 8 >
which is not what I'm looking for.

Is there a way of printing out all of the groups in the above scenario?

I now think that it is not possible, because groups is a method that searches for a regex, rather than being a list.
Reply
#2
Are you using regular expressions here? Please take a moment to re-read your post and consider what context you should be providing that currently isn't here.
Reply
#3
You're joining the representation of a method, because you're not calling it.
Instead of calling group(number), you should call groups() on the match.
This will return the results of all groups in a tuple.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Listing directories (as a text file) kiwi99 1 802 Feb-17-2023, 12:58 PM
Last Post: Larz60+
  Read directory listing of files and parse out the highest number? cubangt 5 2,254 Sep-28-2022, 10:15 PM
Last Post: Larz60+
  Ldap Search for finding user Groups ilknurg 1 1,713 Mar-11-2022, 12:10 PM
Last Post: DeaD_EyE
  Make Groups with the List Elements quest 2 1,936 Jul-11-2021, 09:58 AM
Last Post: perfringo
  Listing All Methods Of Associated With A Class JoeDainton123 3 2,296 May-10-2021, 01:46 AM
Last Post: deanhystad
  Understanding Regex Groups matt_the_hall 5 2,769 Jan-11-2021, 02:55 PM
Last Post: matt_the_hall
  Listing files with glob. MathCommander 9 4,815 Oct-26-2020, 02:04 AM
Last Post: MathCommander
  How to solve equations, with groups of variables and or constraints? ThemePark 0 1,645 Oct-05-2020, 07:22 PM
Last Post: ThemePark
  Listing data from a list ebolisa 1 1,707 Sep-29-2020, 02:24 PM
Last Post: DeaD_EyE
  Create homogeneous groups with Kmeans ? preliator 0 1,501 Sep-01-2020, 02:29 PM
Last Post: preliator

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020