Cause for using objects?

John Heasly jheasly at guardnet.com
Tue Jun 14 18:15:15 EDT 2005


> John Heasly wrote:
>> Given:
>>     [{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 
>> 96.0}, \
>>     {"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 
>> 96.0}, \
>>     {"freehand": "b1.developreport.0614", "width": 154.0, "height":
>> 210.0}, \
>>     {"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 
>> 341.0}]
>>
>> Return:
>>     {"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0,
>> "mugshot1.height": 96.0,\
>>     "mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
>> "mugshot2.height": 96.0, \
>>     "freehand1": "b1.developreport.0614", "freehand1.width": 154.0,
>> "freehand1.width": 210.0, \
>>     "graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0,
>> "graphic1.height": 341.0}
>>
>> I'm trying to teach myself some OOP. Does grinding the Given above 
>> into
>> the Return seem like a good candidate?
>
> If that's all you're doing, and you must use that output format, then
> I'd say no. OOP is not a panacea.
>
> Now if you're going to *do* something with the return information, then
> I would say yes. But in that case, don't use a single dict as a return,
> use objects.
> -- 
> Michael Hoffman

Michael,

Thanks. I'm thinking maybe list comprehension is a more appropriate 
tool. And I need to keep the return a single dict 'cause that's what 
the next step in the process expects.

John




More information about the Python-list mailing list