From: Ian B. <ia...@co...> - 2004-02-21 09:45:42
|
On Feb 19, 2004, at 10:33 PM, jws...@ra... wrote: > If I do a dir() on an instance of my class, I get a list of ALL private > and public attributes. What is the best way for a program containing my > SQLOject to get a list of the public attributes that object exposed in > it's definition, excluding private and inherited items? The printable > representation of the object looks like > > <Customer 6 name='ACME' buyerID=1> > > '_columns' lists the real columns, but not the proxied ones. I could > also > just add a method in my class to return a list of fields. I'm thinking > of generating a gui form based on what the object tells me it's fields > are. Well, AFAIK there's not really a good way to list all the attributes of a class in a general sense. Even hasattr (I believe) just tries to get the attribute, and if it gets an AttributeError it returns false -- there's no backdoor introspection that gives you everything. It can be a little frustrating sometimes. I'd advise that you think about this in more explicit terms -- you aren't exposing all attributes, you really want to expose specific attributes. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |