Re: [Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread Kent Johnson
On Mon, May 19, 2008 at 5:21 PM, Marilyn Davis <[EMAIL PROTECTED]> wrote: > Hi Tutors and Tutees, > > I've been teaching Python quite a while and a brilliant student asked a > question that made me realize a big hole in my understanding. > > I think it is really magical that, when I define __getite

Re: [Tutor] New Style Classes, __getitem__ and iteration

2008-05-19 Thread wesley chun
> I think it is really magical that, when I define __getitem__ on classic > classes, the built-in iterator uses it. > > But, when I make the same class as a new style class, I lose this behavior. > > I didn't realize that something was lost in defining a new style class. > Maybe it's something

Re: [Tutor] New-style classes

2005-09-29 Thread Kent Johnson
Jan Eden wrote: > My actual code looks like this: > > class Base: > def GetOwnType(self): > try: return self._own_type > except: return self.child_type > > def SetOwnType(self, value): > self._own_type = value > > own_type = property(GetOwnType, Se

Re: [Tutor] New-style classes

2005-09-29 Thread Jan Eden
Hi Kent, Kent Johnson wrote on 29.09.2005: >>Data.Base has no base classes, so it is not based on a built-in >>type: How can it be a new-style class? > >Data.Base is not a new-style class, but the classes in Show are. And >properties may appear to work in old-style classes. This document >http://

Re: [Tutor] New-style classes

2005-09-29 Thread Kent Johnson
Jan Eden wrote: > Hi, > > after updating a program to use new-style classes, I am a bit confused. My > setup looks like this (simplified): > > #Show.py > > import Data > > class Base(object): > ... > > class Page(Data.Page, Base): > ... > > class Author(Data.Author, Base): > ...