Getting a dictionary from an object
Thanos Tsouanas
thanos at sians.org
Sun Jul 24 05:03:47 EDT 2005
On Sun, Jul 24, 2005 at 01:43:43PM +1000, Steven D'Aprano wrote:
> On Sun, 24 Jul 2005 02:09:54 +0300, Thanos Tsouanas wrote:
> >
> > print foo %do
> >
> > where do is a dictobj object...
>
> Are you telling me that the ONLY thing you use dictobj objects for is to
> print them?
I'm sorry to disappoint you, but yes. When you have a long text
template to fill-out, with lots of %(foo)s, and all those foos are
attributes of an object, it really helps to have dictobj.
> I don't think so. I do know how to print an object, amazingly.
Please, tell me, how would you print it in my case?
> Perhaps you would like to explain how you use the rest of the
> functionality of the dictobj, instead of taking my words out of context
> and giving an inane answer.
I dont see _ANY_ other functionality in the dictobj class. Do you?
> Why jump through all those hoops to get attributes when Python already
> provides indexing and attribute grabbing machinery that work well? Why do
> you bother to subclass dict, only to mangle the dict __getitem__ method so
> that you can no longer retrieve items from the dict?
Because *obviously* I don't know of these indexing and attribute
grabbing machineries you are talking about in my case. If you cared to
read my first post, all I asked was for the "normal", "built-in" way to
do it. Now, is there one, or not?
--
Thanos Tsouanas .: My Music: http://www.thanostsouanas.com/
http://thanos.sians.org/ .: Sians Music: http://www.sians.org/
More information about the Python-list
mailing list