Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3802044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:08:45+00:00 2026-05-19T14:08:45+00:00

I have been playing around with regular expressions and was trying to subclass the

  • 0

I have been playing around with regular expressions and was trying to subclass the MatchObject that is returned from re.search.

I have had no luck getting access to the MatchObject class.

I assume enter code herethat the actual type of this object is not called “MatchObject”:

>>> re.search ("a", "a")
<_sre.SRE_Match object at 0x100427a58>

However, I am not able get access to this object:

import _sre

dir (_sre)
['CODESIZE', 'MAGIC', '__doc__', '__name__', '__package__', 'compile', 'copyright', 'getcodesize', 'getlower']

>>> dir(_sre.SRE_Match)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SRE_Match'

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:08:45+00:00Added an answer on May 19, 2026 at 2:08 pm

    It’s not gonna happen 🙂

    >>> import re
    >>> mo = re.search ("a", "a")
    >>> mo_class = type(mo)
    >>> mo_class
    <type '_sre.SRE_Match'>
    >>> class SubClass(mo_class):
    ...     pass
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: Error when calling the metaclass bases
        type '_sre.SRE_Match' is not an acceptable base type
    

    It’s worth noting that you can always get access to the type of an object by calling type(obj) though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been playing around with a search control and i have noticed that
I'm very new to javascript and have been playing around with regular expressions. I'm
I have been playing around a bit with a fairly simple, home-made search engine,
I have been playing around with NSURLConnection. Now I'm trying to grab some data
I have been playing around with creation of pdf documents for a project that
I have been playing around with different scripts, I found one that works for
I have been playing around with some debugging and wrote some C code that
I have been playing around with node.js, and coming from a Java background, I
I have been playing around with haskell and I found out that if I
I have been playing around with tableviews for the past few days trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.