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 if your class doesn't
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):
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 clearly enough
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'.
class
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.__getitem__
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 (exceptions...)
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 the
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'.
class
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
Then
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?
Apart
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 model
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 canonical
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 there.
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 attributes can
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, and at any
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
16 matches
Mail list logo