Cousson, Benoit a écrit :
(snip)
Now if you say; it is not supported, don't do that, we will deprecate
that feature, fine, I will use an alternative solution.
I was just not aware of that "nested class is evil" group in the
Python community.
Probably because this group is mostly composed of Mr
Calvin Spealman a écrit :
(snip)
I know every rule has its exceptions. I put "don't nest classes" in
with other similar rules I will claim, where I think its safest to say
"Never do this!",
I know (from experience) and understand why goto's and globals are
(usually) evil, I know why public att
Calvin Spealman a écrit :
On Wed, Aug 13, 2008 at 11:32 AM, Cousson, Benoit <[EMAIL PROTECTED]> wrote:
(snip)
There is no point of nested classes because nested classes _are not_
supported by python.
Depending on the definition of "supported".
(snip)
In my case, I'm trying to use a simila
On Wed, 13 Aug 2008 23:40:50 -0400, Calvin Spealman wrote:
> I know every rule has its exceptions. I put "don't nest classes" in with
> other similar rules I will claim, where I think its safest to say "Never
> do this!", because only then will you know that, should you actually do
> it at some po
On Wed, Aug 13, 2008 at 10:49 PM, Carl Banks <[EMAIL PROTECTED]> wrote:
>> 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 t
On Aug 13, 11:38 am, "Calvin Spealman" <[EMAIL PROTECTED]> wrote:
> 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
Calvin Spealman a écrit :
On Wed, Aug 13, 2008 at 7:41 PM, Maric Michaud <[EMAIL PROTECTED]> wrote:
I was not aware of any "nested classes are unsupported" before and didn't
consider nested classes as bad practice till now, even with the pickle
limitation (not every class are intended to be pick
Le Wednesday 13 August 2008 21:04:30 Rhamphoryncus, vous avez écrit :
> class X(object):
> foo = 42
>
> def bar(self):
> print foo
> print self.foo
> X.foo = 7
Yes this is a problem, function could not bind their free vars to the class
namespace without introducing a subtl
On Wed, Aug 13, 2008 at 7:41 PM, Maric Michaud <[EMAIL PROTECTED]> wrote:
> I was not aware of any "nested classes are unsupported" before and didn't
> consider nested classes as bad practice till now, even with the pickle
> limitation (not every class are intended to be pickled), more you didn't g
Le Tuesday 12 August 2008 23:15:23 Calvin Spealman, vous avez écrit :
> The issue has been brought up several times before. There have been
> proposals to make nested classes better supported, but they are always
> shut down. The vote is always against it. Your metaclass example is
> one thing, bu
On Aug 13, 11:13 am, "Cousson, Benoit" <[EMAIL PROTECTED]> wrote:
> > 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
>
> 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
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
> 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 a
The issue has been brought up several times before. There have been
proposals to make nested classes better supported, but they are always
shut down. The vote is always against it. Your metaclass example is
one thing, but its not really applicable here. I've never seen or
would encourage nested cla
Please re-evaluate your "need" for nesting classes in the first place.
On Tue, Aug 12, 2008 at 1:06 PM, Cousson, Benoit <[EMAIL PROTECTED]> wrote:
>> This is a language limitation.
>> This is because nested scope is implemented for python function only since
>> 2.3
>> allow late binding of free va
> This is a language limitation.
> This is because nested scope is implemented for python function only since
> 2.3
> allow late binding of free variables. the scope in class statment is not a
> closure, so there is only two possible scope in it : local and global.
That was my understanding as wel
The simple answer is "Dont nest classes. It is not supported."
What you are seeing is really an artifact of how classes are built.
Basically, everything inside the class body has to exist before it can
run, so the inner classes code objects are actually created first.
However, the class object its
> I'm wondering as well if the new nonlocal statement will fix that in py3k?
The "class C3" statement is executing before the "class B" statement
has concluded, so at that time B does not exist in any scope at all,
not even globals(). You could reference B.C1 inside a method because a
method is ex
Le Tuesday 12 August 2008 11:29:18 Cousson, Benoit, vous avez écrit :
> Hi,
>
> I'd like to be able to use a nested class (C1) from another sibling nested
> class (C3). This looks very similar to the nested scopes of functions
> except that it does not work.
>
> class A(object):
> pass
>
> cl
20 matches
Mail list logo