Object's nesting scope
zaur
szport at gmail.com
Thu Aug 27 11:01:14 EDT 2009
On 27 авг, 18:34, Carl Banks <pavlovevide... at gmail.com> wrote:
> On Aug 26, 5:51 am, zaur <szp... at gmail.com> wrote:
>
>
>
> > Hi folk!
>
> > What do you think about idea of "object's nesting scope" in python?
>
> > Let's imaging this feature, for example, in this syntax:
>
> > obj=<expression>:
> > <body>
>
> > or
>
> > <expression>:
> > <body>
>
> > That's means that result object of <expression> evaluation is used as
> > nested scope for <body> evaluation.
>
> > So is this idea useful?
>
> It might be marginally useful to save typing.
It also allow to structure the code.
> The idea has been
> discussed in various forms here quite a bit over the years. I doubt
> there's any chance it'll be accepted into Python, because it goes
> against one of the main design points of Python: that attributes
> should always be accessed explicitly.
I don't in general consider this idea as a way for implicit access to
object's attributes.
Idea is about to use in some way object's dictionary as nested scope
in a code block.
I agree though that using this only for saving typing or implicit
attribute access isn't a good idea.
> Having said that, the syntax you propose is awful. :) Normally when
> this is proposed they use a keyword such as "using":
>
> p = Person()
> using p:
> name = "Carl Banks"
> location = "Los Angeles"
>
> or, perhaps to save a line (even though it'd be a minor syntax abuse):
>
> using Person() as p:
> name = "Carl Banks"
> location = "Los Angeles"
I don't propose concrete syntax for using object's dictionary as
nested scope.
I used current only to explain the idea.
More information about the Python-list
mailing list