Anand wrote:
>
> On 02-Oct-07, at 9:18 AM, Tzury wrote:
>
>> utils.Storage is one of the reusable components that makes one wonder
>> how come it is not integral part of Python. It gives my configuration
>> files an elegant name-spacing, and I use it instead of dict anywhere
>> it make sense.
>
> You can't always use it as replacement of dict. You have to be
> careful about the methods of dict.
>
> >>> d = web.storage()
> >>> d.keys = [1, 2]
> >>> d.keys
> <built-in method keys of Storage object at 0x11770c8>
>
>> hard-coding came out simple:
>> Instead of:
>> x = Storage({'server': {'username': 'root', 'password': 'pa$$word',
>> 'ip': '1.1.1.1'}})
>> I can write:
>> x = Storage({'server': Storage( {'username': 'root', 'password': 'pa$
>> $word', 'ip': '1.1.1.1'})})
>
> Zen of Python:
>
> Explicit is better than Implicit.
I agree here, it seems like a very bad idea to change what the
programmer entered as a dictionary into a storage object just like that.
There are quite some of examples of how this can go wrong (keys like "é"
or "1" or 1), not to mention the fact that it just "does not feel right"
(like Anand mentioned). The advantages seem quite insignificant compared
to that.
b^4
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---