Diez,
Thanks, you're right.
Delegated attributes are not in the dir() result.
>>getattr(reg, "pattern")
'[0-9]+'
>>getattr(reg, "flags")
0
>>getattr(reg, "groupindex")
{}
Tomohiro Kusumi
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
3 941
On Jun 5, 7:11*am, Tomohiro Kusumi <kusumi.tomoh...@jp.fujitsu.com>
wrote:
>
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.
Didn't I read that Py3 will support a __dir__ method so that classes
*could* report such pseudo-attributes in response to dir?
-- Paul
Paul McGuire wrote:
On Jun 5, 7:11 am, Tomohiro Kusumi <kusumi.tomoh...@jp.fujitsu.com>
wrote:
>>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.
Didn't I read that Py3 will support a __dir__ method so that classes
*could* report such pseudo-attributes in response to dir?
It's already there in 2.6:
.... class X (object):
.... def __init__ (self, a, b):
.... self.a = a
.... self.b = b
.... def __dir__ (self):
.... return ['a', 'b', 'c']
....
>>dir (X (1, 2))
['a', 'b', 'c']
>>>
TJG
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.
Didn't I read that Py3 will support a __dir__ method so that classes
*could* report such pseudo-attributes in response to dir?
-- Paul
I don't believe that it possibly could:
class foo(object):
def __getattr__(self, what):
if what[0] == 't':
return True
f = foo()
print f.toby
** Posted from http://www.teranews.com ** This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: praba kar |
last post by:
Dear All,
In Php we can do all the mailing operations like
sending a text as a message, adding attachment to a
mail, adding additional headers and so on using
Mail_mime class. I want to know...
|
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...
|
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...
|
by: Paminu |
last post by:
I am trying to split my program in different parts.
I have a file called mainfile.c that contains the main() function, some
global variables and a few other functions.
I then have a file...
|
by: fh1996 |
last post by:
csc /target:module MyMod.cs
What's meaning of "NETMODULE"?
Is /target:module always going to generate xxx.netmodule?
Does C# compiler only generate the following 3 types of files: .EXE, .DLL...
|
by: sam_cit |
last post by:
Hi Everyone,
I had a doubt regarding extern decleration, i tried this is one
source file,
extern int sample;
extern int sample;
int main()
{
|
by: Jim Flanagan |
last post by:
Hello -
I am in need of more help regarding an approach to accomplishing the
following:
We have a need to change the Volume serial numbers of a bunch of
preprogrammed IDE Solid State Drive...
|
by: Tomohiro Kusumi |
last post by:
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...
|
by: Jeremy Banks |
last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the
Popen class in the subprocess module. Popen sounds like the a suitable
name for a function that created a subprocess, but the...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |