473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question regarding re module

Hi,

I have a question regarding re module.
# By the way I'm not in this list, so I'm sorry but please CC me.

I tried following code in Python shell using a regular expression.
Why doesn't the result of dir(reg) have 'pattern', 'flags', and
'groupindex' although they exist as members of _sre.SRE_Pattern
instance ?

It sort of irritates me, because whenever I write Python code
using a module which I'm not used to using, I often try Python
shell with TAB complete to find out the member of module/instance.

Tomohiro Kusumi

-------------------------------------------------
Python 2.5 (r25:51908, May 16 2008, 13:41:55)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import re
reg = re.compile(r"[0-9]+")
reg.pattern
'[0-9]+'
>>reg.flags
0
>>reg.groupindex
{}
>>dir(reg)
['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner',
'search', 'split', 'sub', 'subn']
>>reg.<TAB>
reg.__copy__ reg.finditer reg.search reg.subn
reg.__deepcopy__ reg.match reg.split
reg.findall reg.scanner reg.sub

Jun 27 '08 #1
1 933
Tomohiro Kusumi schrieb:
Hi,

I have a question regarding re module.
# By the way I'm not in this list, so I'm sorry but please CC me.

I tried following code in Python shell using a regular expression.
Why doesn't the result of dir(reg) have 'pattern', 'flags', and
'groupindex' although they exist as members of _sre.SRE_Pattern
instance ?

It sort of irritates me, because whenever I write Python code
using a module which I'm not used to using, I often try Python
shell with TAB complete to find out the member of module/instance.
It could be that the result overloads the __getattr__-method to delegate
calls to some object. Thus it's not part of the outer instance.

Diez
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: It's me | last post by:
This must be another newbie gotchas. Consider the following silly code, let say I have the following in file1.py: #============= import file2 global myBaseClass myBaseClass =...
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
3
by: Samuel | last post by:
I wrote a very simple httpmodule and tried to compile it with no success. This is my code: ============== Imports System Imports System.Web Imports Microsoft.VisualBasic NameSpace...
1
by: z. f. | last post by:
Hi, I have a deployment question for a migration from ASP to ASP.NET. the application is an e-commerce web-site that have loadbalancing of 4 web servers running (today) windows2000 with IIS5 and...
2
by: RSH | last post by:
Hi, i have a situation where I have a VB .Net Module built that contains all of the functions I need. I now need to add a form to the project and i need the form to sdisplay and the module code...
2
by: Dean R. Henderson | last post by:
For an ASP.NET web application, is there a way for one session (with appropriate security authorization) to set a HttpSessionState variable to point to another session and execute the Abandon...
3
by: John Wright | last post by:
How can I set the property of a loaded Assembly using reflection. My Shell program will log in a person and retrieve a list of all programs the person can use. When the shell program launches a...
1
by: m.banaouas | last post by:
Hello Pythoneers: I would like to ask you a simple question: Are you satisfied by SOAPpy module? Actually, I use this module since a year and i immediately found it very well-implemented,...
3
by: Tomohiro Kusumi | last post by:
Diez, Thanks, you're right. Delegated attributes are not in the dir() result. '+' 0 {} Tomohiro Kusumi
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.