En Sat, 29 Aug 2009 04:34:48 -0300, zaur <
[email protected]> escribió:
En Fri, 28 Aug 2009 15:25:55 -0300, zaur <
[email protected]> escribió:
On 28 авг, 16:07, Bruno Desthuilliers <bruno.
(e-mail address removed)> wrote:
zaur a écrit :
Ok. Here is a use case: object initialization.
Err... Looks like you really should read the FineManual(tm) -
specifically, the parts on the __init__ method.
What are you doing if 1) classes Person and Address imported from
foreign module 2) __init__ method is not defined as you want?
Welcome to dynamic languages! It doesn't matter *where* the class was Â
defined. You may add new attributes to the instance (even methods to Â
the class) at any time. [...4 examples...]
I know about these ways of object initializing. What I said is about
using object's dictionary as nested scope in code block. Object
initialization is just one use case.
So we say about different things.
Well, you asked how to proceed in certain cases and I showed several ways Â
it can be done right now, without requiring a new scope. You'll have to Â
think of another use case.
Attribute lookup is explicit in Python, and that's a very good thing. If Â
you follow the python-ideas thread posted earlier, you'll see the kind of Â
problems an implicit attribute lookup would cause. The "with" statement is Â
necesary (and a good thing) in Pascal, but not in Python.
Zope2 departs from this explicitness: it has a <dtml-with> construct Â
(similar to what you propose), and I hate it profoundly every time I have Â
to edit a DTML file - I can never tell *where* an attribute comes from. Â
Another related "feature" is acquisition, a stack of namespaces where Â
objects "inherit" attributes from their containers. Same thing, a complete Â
waste of time every time I have to track a bug.
Unless you can find a very compeling use case, I don't think this feature Â
will become part of the language anytime soon...