On Wed, Aug 13, 2008 at 11:32 AM, Cousson, Benoit <[EMAIL PROTECTED]> wrote:
>> Defining it as a nested class saves you one line
>> of code, but IMHO makes the result just a bit more cluttered, while
>> reducing the elegance of reusing the metaclass.
>
> The whole point of nested class is to avoid polluting the namespace with 
> classes that are only used locally. So the argument about the elegance of 
> reusing is not very valid in that case.

There is no point of nested classes because nested classes _are not_
supported by python. They are simply an artifact of not actively
denying the syntax non-globally. I would fully support a change to the
language to actively forbid a class definition that is not
module-level.

> I agree that they are other ways using module to avoid namespace pollution, 
> but in some case it is easier to use nested class instead and keep everything 
> in the same file.

I don't consider it pollution. If you want it considered "private" to
the module, name it with an underscore.

> In my case, I'm trying to use a similar approach as XIST's one, meaning using 
> Python class to model hierarchical data. So clearly nested class is a very 
> nice and easy understandable way to do that.

I don't find that this is clear in anyway. I can't imagine why you'd
think a nested class is even useful here, rather than an instance with
some understandable attributes. I've seen a lot of places nested
classes are used and not one of them that should be been doing it.

But, on that note, there is a point where a discussion is obviously
not going to resolve with either side changing their minds. This is
obviously such a case.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to