Dictionary self lookup

Norberto Lopes shelika.void at gmail.com
Wed Jun 24 06:22:48 EDT 2009


On Jun 24, 12:05 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Wed, Jun 24, 2009 at 2:39 AM, Norberto Lopes<shelika.v... at gmail.com> wrote:
> > Hi all.
> > Assuming that python dictionaries already provide a bit of "shoot
> > yourself in the foot", I think what I have in mind would not be so
> > bad.
>
> > What do you think of dictionaries having a self lookup in their
> > declaration?
>
> > Be able to do this:
>
> > a = {"foo" : "foo1", "bar" : a["foo"]} # or with another syntax
>
> > instead of:
>
> > a = { "foo" : "foo1" }
> > a["bar"] = a["foo"]
>
> > Maybe I'm murdering python syntax/philosophy right here so let me know
> > if that's the case.
>
> The idea sounds quite confusing and seems unnecessary.
>
> Specifically, your proposal appears to contravene the following points
> of the holy Zen of Python:
>
> - Explicit is better than implicit.
> - Readability counts.
> - Special cases aren't special enough to break the rules.
> - In the face of ambiguity, refuse the temptation to guess.
> - If the implementation is hard to explain, it's a bad idea.
>
> Cheers,
> Chris
> --http://blog.rebertia.com


Ok, no arguments against this one :(

/agree



More information about the Python-list mailing list