Question regarding re module
kusumi.tomohiro at jp.fujitsu.com
Thu Jun 5 14:11:45 CEST 2008
Thanks, you're right.
Delegated attributes are not in the dir() result.
>>> getattr(reg, "pattern")
>>> getattr(reg, "flags")
>>> getattr(reg, "groupindex")
> Tomohiro Kusumi schrieb:
>> 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.
More information about the Python-list