[Python-ideas] Dict-like object with property access
g.brandl at gmx.net
Wed Feb 1 20:35:04 CET 2012
Am 01.02.2012 14:32, schrieb Massimo Di Pierro:
> Using x:[....] wouldn't it create ambiguities when parsing (lambda x:[....])?
> How about x. as a shortcut for x.__dict__ so we can do
> x.key -> x.__dict__['key']
> x.[key] -> x.__dict__[key]
> x..keys() -> x.__dict__.keys()
> x..values() -> x.__dict__.values()
> for attribute in x.:
> print 'x.'+attribute
> and leave open the possibility of 3 dots for for ranges
> 1...5 -> range(1,5)
Actually no, because 1. is a float literal. So
would already be valid, and you have to use four dots for ranges.
I would suggest five to be on the safe side (plus it has as many
dots as there are letters in "range", therefore easy to remember).
More information about the Python-ideas