[Python-ideas] Dict-like object with property access

Masklinn masklinn at masklinn.net
Wed Feb 1 14:44:09 CET 2012


On 2012-02-01, at 14:32 , Massimo Di Pierro wrote:
> 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)
> 1,2...10 -> range(1,10,2-1)

Yeah, readability schmeadability.

Also, 

    >>> 1..__int__()
    1

that's going to look good.


More information about the Python-ideas mailing list