Re: Trying to understand Python objects

2006-11-24 Thread Aahz
In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >Aahz a écrit : >> In article <[EMAIL PROTECTED]>, >> Ben Finney <[EMAIL PROTECTED]> wrote: >>> >>>Typically, classes are created as a subclass of another class. The >>>top-level basic type in Python is 'object', so i

Re: Trying to understand Python objects

2006-11-23 Thread Carl Banks
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Ben Finney <[EMAIL PROTECTED]> wrote: > > > >Typically, classes are created as a subclass of another class. The > >top-level basic type in Python is 'object', so if your class doesn't > >make sense deriving from anything else, derive from 'object'.

Re: Trying to understand Python objects

2006-11-23 Thread Bruno Desthuilliers
Fredrik Lundh a écrit : > Bruno Desthuilliers wrote: > >> Don't see it as a religious point please, but I fail to understand why >> you seem so in love with old-style classes ? (snip) > > to pick a few reasons: the old-style/new-style distinction is com- > pletely irrelevant for people new to t

Re: Trying to understand Python objects

2006-11-23 Thread Fredrik Lundh
Bruno Desthuilliers wrote: > Don't see it as a religious point please, but I fail to understand why > you seem so in love with old-style classes ? new-style classes are the > "official" Python object model since 2.2 (which is a few years ago now), > and the last mandatory use of them (exception

Re: Trying to understand Python objects

2006-11-23 Thread George Sakkis
Bruno Desthuilliers wrote: > AFAIK, everything you do with old-style classes can be done with new-style > ones. The only thing I occasionally (or rather rarely) miss about old-style classes is instance-specific special methods: >>> class C: ... def __init__(self,x): ... self.__getit

Re: Trying to understand Python objects

2006-11-23 Thread Bruno Desthuilliers
Aahz a écrit : > In article <[EMAIL PROTECTED]>, > Ben Finney <[EMAIL PROTECTED]> wrote: > >>Typically, classes are created as a subclass of another class. The >>top-level basic type in Python is 'object', so if your class doesn't >>make sense deriving from anything else, derive from 'object'. >>

Re: Trying to understand Python objects

2006-11-23 Thread Aahz
In article <[EMAIL PROTECTED]>, walterbyrd <[EMAIL PROTECTED]> wrote: > >Is there some book, or other reference, that explains of this? I was >thinking about "Python for Dummies." The "Think like a Computer >Scientist" book, and "Dive into Python" book don't seem to explain >Python's object model c

Re: Trying to understand Python objects

2006-11-23 Thread Aahz
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > >Typically, classes are created as a subclass of another class. The >top-level basic type in Python is 'object', so if your class doesn't >make sense deriving from anything else, derive from 'object'. > >class Point(object

Re: Trying to understand Python objects

2006-11-22 Thread Ben Finney
"walterbyrd" <[EMAIL PROTECTED]> writes: > Is there some book, or other reference, that explains of this? I was > thinking about "Python for Dummies." The "Think like a Computer > Scientist" book, and "Dive into Python" book don't seem to explain > Python's object model clearly enough for me. The

Re: Trying to understand Python objects

2006-11-22 Thread walterbyrd
Thanks everybody. I will sort all of this out, but right now my head is spinning. Is there some book, or other reference, that explains of this? I was thinking about "Python for Dummies." The "Think like a Computer Scientist" book, and "Dive into Python" book don't seem to explain Python's object

Re: Trying to understand Python objects

2006-11-22 Thread Bruno Desthuilliers
walterbyrd wrote: > Reading "Think Like a Computer Scientist" I am not sure I understand > the way it describes the way objects work with Python. > > 1) Can attributes can added just anywhere? I create an object called > point, then I can add attributes any time, and at any place in the > program?

Re: Trying to understand Python objects

2006-11-22 Thread Fredrik Lundh
walterbyrd wrote: > 1) Can attributes can added just anywhere? I create an object called > point, then I can add attributes any time, and at any place in the > program? in general, yes, but that should be done sparingly. > 2) Are classes typically created like this: > > class Point: > pass >

Re: Trying to understand Python objects

2006-11-21 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > Or, the attributes are added to a specific instance (often in the > initialisation method) so that each instance has a separate attribute > with the same name:: The example here should have been:: class Point(object): spam = 4 def __in

Re: Trying to understand Python objects

2006-11-21 Thread George Sakkis
James Stroud wrote: > walterbyrd wrote: > > Reading "Think Like a Computer Scientist" I am not sure I understand > > the way it describes the way objects work with Python. > > > > 1) Can attributes can added just anywhere? I create an object called > > point, then I can add attributes any time, an

Re: Trying to understand Python objects

2006-11-21 Thread Ben Finney
"walterbyrd" <[EMAIL PROTECTED]> writes: > Reading "Think Like a Computer Scientist" I am not sure I understand > the way it describes the way objects work with Python. Congratulations for taking the effort to figure it out, and for thinking about the questions you want answered. > 1) Can attrib

Re: Trying to understand Python objects

2006-11-21 Thread Robert Kern
Ben Finney wrote: > Or, the attributes are added to a specific instance (often in the > initialisation method) so that each instance has a separate attribute > with the same name:: > > class Point(object): > spam = 4 > def __init__(self): > eggs = 2 There's a typo