Tzury wrote:
>> 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.
>
> The programmer is me I am aware of what I am doing with my code.
> If one is not sure about the keys, the [""] notation can always used.
>
> The all concept lays behind Storage is to add the dot notation (see
> documentation in the code).
> If one wish to stick with [''] approach why using Storage at first
> place.
>
> Since dict can be nested I thought Storage also should be nested
> without extra tweak.
> So if you pass {'foo': {'bar': 'baz'} to Storage why stopping at first
> level and and not letting the Storage drilling down through the data
> structure.
This is not a matter of recursion, this is a matter of arguments and
intuitiveness. {'foo': {'bar': 'baz'}} is one object: a dictionary. That
it contains another dictionary does not say anything about the object
itself. If I create an instance of the Storage class, I do it by writing
Storage(some_argument), calling __init__ and passing it an argument. It
is logical that __init__ interprets this argument to mean something, it
is intuitive that it modifies it, uses it, et etcetera. What is not
expected is that __init__ would actually descend into this object and
apply itself to children it sees fit to apply itself to. When I call
__init__ with a certain argument, I want (and expect!) it to look at
that argument, that object, not at other things.
If I do want it and know it, I can specify it. If I do not want it, I
can leave it out. The only down-side is if I do feel the need for nested
Storage objects, it takes more code ("Storage()", to be precise).
Compare this situation to your proposal; there is a more serious
down-side: if I do not know/expect it to happen (and this is very
plausible) it can cause problems (sometimes I really want a dict, not a
Storage instance). If I /do/ know it, I have to explicitly tell Storage
not to work recursively, not always pretty.
Anyway, my main problem with this is that people absolutely will not see
this coming.
Greetings,
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
-~----------~----~----~----~------~----~------~--~---