Getting the "dir" from the other ancestor ?
alessiogiovanni.baroni at gmail.com
Tue Apr 28 15:18:25 CEST 2009
On 28 Apr, 15:01, Stef Mientki <stef.mien... at gmail.com> wrote:
> I have a class, derived from some user defined class
> (User_Defined_Ancestor) and some basic class (Basic_Ancestor).
> One of the major tasks of the Basic_Ancestor,
> is to hide all kinds of implementation details for the user,
> so the user can concentrate on the functional design.
> One of things I need to know are the methods and attributes of the
> Both classes are dynamic, i.e. attributes are added during run time.
> class Master ( User_Defined_Ancestor, Basic_Ancestor ) :
> def __init__ ( self, *args, **kwargs ) :
> Basic_Ancestor.__init__ ( self, *args, **kwargs )
> class Basic_Ancestor ( object ) :
> def __init__ ( self, .... ) :
> self.other = dir ( User_Defined_Ancestor )
> def Get_Attributes ( self ) :
> return dir ( self ) - dir ( self.other )
> Now the problem is, I don't know "User_Defined_Ancestor" in Basic_Ancestor.
> I can't pass it through the parameter list, because I use "*args, **kwargs"
> I possibly could use some global variable, but that's not my preference.
> Any other suggestions ?
> Stef Mientki
In anytime, if you do dir() in a class B, that extends a class A, you
have all fields of A also.
>>> class A:
... def a(self):
... return 0
>>> class B(A):
... def b(self):
... return 5
[......, 'a', 'b']
More information about the Python-list