Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-08 Thread marek . rocki
Everybody has already explained why this doesn't work and a possible "solution" using metaclasses was suggested. I tried to implement it, ended up with monkey-patching __bases__, which is certainly an abomination (will it be possible in python 3.0?) but seems to do the trick. class _InheritFromOut

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-08 Thread castironpi
On Mar 7, 7:46 pm, DBak <[EMAIL PROTECTED]> wrote: > > > > >  However I can't do this, because, of course, the name Tree isn't > > > > >  available at the time that the classes _MT and _Node are defined, so > > > > >  _MT and _Node can't inherit from Tree. > > > > > Not only is the name not defined

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread DBak
On Mar 7, 3:41 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 4:39 pm, DBak <[EMAIL PROTECTED]> wrote: > > > On Mar 7, 1:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > > > > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > > > >  However I can't do this, because, of course, the name

Re: Nested phrases [was Re: Want - but cannot get - a nested class to inherit from outer class]

2008-03-07 Thread castironpi
On Mar 7, 6:39 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 14:26:25 -0800, castironpi wrote: > > Humans have enormous "mental stacks"--- the stacks the contexts the > > speakers speak in push things they're hearing on to. > > This is not true. Oh yeah.

Nested phrases [was Re: Want - but cannot get - a nested class to inherit from outer class]

2008-03-07 Thread Steven D'Aprano
On Fri, 07 Mar 2008 14:26:25 -0800, castironpi wrote: > Humans have enormous "mental stacks"--- the stacks the contexts the > speakers speak in push things they're hearing on to. This is not true. Human beings have extremely shallow mental stacks, limited by short-term memory. Most people are c

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread castironpi
On Mar 7, 4:39 pm, DBak <[EMAIL PROTECTED]> wrote: > On Mar 7, 1:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > > > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > > >  However I can't do this, because, of course, the name Tree isn't > > >  available at the time that the class

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread DBak
On Mar 7, 1:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > >  However I can't do this, because, of course, the name Tree isn't > >  available at the time that the classes _MT and _Node are defined, so > >  _MT and _Node can't in

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread castironpi
On Mar 7, 3:19 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > > >  I would like to build a class for a data structure such that nodes of > >  the data structure - of interest only to the data structure > >  implementation itself and

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread Chris Mellon
On Fri, Mar 7, 2008 at 3:00 PM, DBak <[EMAIL PROTECTED]> wrote: > I want - but cannot get - a nested class to inherit from an outer > class. (I searched the newsgroup and the web for this, couldn't find > anything - if I missed an answer to this please let me know!) > > I would like to build a

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread Jeff
Use metaclasses? DBak wrote: > I want - but cannot get - a nested class to inherit from an outer > class. (I searched the newsgroup and the web for this, couldn't find > anything - if I missed an answer to this please let me know!) > > I would like to build a class for a data structure such that

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread DBak
Sorry - code for the class should read: class Tree(object): ...class _MT(Tree): ..def isEmpty(self): return True ..def insert(self, X): return Tree._Node(X) ...class _Node(Tree): ..def isEmpty(self): return False ..def insert(self, X): return _Node(X, self, Tree._MT()) ...def __ini

Want - but cannot get - a nested class to inherit from outer class

2008-03-07 Thread DBak
I want - but cannot get - a nested class to inherit from an outer class. (I searched the newsgroup and the web for this, couldn't find anything - if I missed an answer to this please let me know!) I would like to build a class for a data structure such that nodes of the data structure - of intere