RE: [PyCrust] Attribute list hook
Brought to you by:
pobrien
|
From: Patrick K. O'B. <po...@or...> - 2001-08-12 13:48:18
|
Rather than adopt a naming convention inside of PythonWin or PyCrust, how
about adding a function as a parameter to our "getAttributes" functions? So
PyCrust would look something like:
def getAttributes(self, object, getMore=None):
# Return a list of attributes, including inherited, for an object.
try:
attributes = dir(object)
if hasattr(object, '__class__'):
attributes += self.getAttributes(object.__class__)
try:
attributes += getMore(object)
except:
pass
if hasattr(object, '__bases__'):
...
That way the function passed in as getMore has the opportunity to be named
anything and to do anything.
P.S. These methods got recast as functions and now reside in the introspect
module in CVS. They were also rewritten a bit. Just FYI.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
-----Original Message-----
From: pyc...@li...
[mailto:pyc...@li...]On Behalf Of Neil Hodgson
Sent: Saturday, August 11, 2001 7:37 PM
To: pyc...@li...
Subject: Re: [PyCrust] Attribute list hook
Mark Hammond:
> I like the idea, but would prefer to see one or 2 leading "_" on the name.
> Considering a COM object, for example, the potential exists that
> "getAttributeNames" could be a real method on the object. A leading _
also
> helps reinforce this is not a method designed to be called by the
"average"
> user of the object.
OK. I wasn't sure about the conventions behind "_" and "__" and which is
correct here. I think of "_" as a simple "private" and "__" as "deep
implementation mystery".
Neil
_______________________________________________
PyCrust-users mailing list
PyC...@li...
http://lists.sourceforge.net/lists/listinfo/pycrust-users
|