From ecbb0eaa43938e75afe4e1a4c122c3dc64290fdd Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 18 Oct 2002 15:40:13 +0000 Subject: Update docs. Remove old classes.doc. --- Demo/classes/README | 3 +- Demo/classes/class.doc | 110 ------------------------------------------------- 2 files changed, 1 insertion(+), 112 deletions(-) delete mode 100755 Demo/classes/class.doc diff --git a/Demo/classes/README b/Demo/classes/README index cca7524..1d41f6a 100644 --- a/Demo/classes/README +++ b/Demo/classes/README @@ -10,5 +10,4 @@ Vec.py A simple vector class bitvec.py A bit-vector class by Jan-Hein B\"uhrman (For straightforward examples of basic class features, such as use of -methods and inheritance, see the library code -- especially the window -modules are full of them.) +methods and inheritance, see the library code.) diff --git a/Demo/classes/class.doc b/Demo/classes/class.doc deleted file mode 100755 index fddc60b..0000000 --- a/Demo/classes/class.doc +++ /dev/null @@ -1,110 +0,0 @@ -New features of classes -======================= - -A class can implement certain operations that are invoked by special -syntax (such as subscription or arithmetic operations) by defining -methods with special names. - - -Special methods for any type ----------------------------- - -__repr__(self) --> string - -Used by the print statement and conversions (reverse quotes) to -compute the string representation of an object. - -__cmp__(self, other) --> int - -Used by all comparison operations. Should return -1 if selfother. Due to limitations in the -interpreter, exceptions raised by comparisons are ignored, and the -objects will be considered equal in this case. - - -Special methods for sequence and mapping types ----------------------------------------------- - -__len__(self) --> int - -Used by the built-in function len(). Should return the length of the -object, which should be >= 0. Also, an object whose __len__() method -returns 0 - -__getitem__(self, key) --> value - -Used to implement value = self[key]. Note that the special -interpretation of negative keys (if the class wishes to emulate a -sequence type) is up to the __getitem__ method. - -__setitem__(self, key, value) - -Used to implement self[key] = value. Same note as for __getitem__. - -__delitem__(self, key) - -Used to implement del self[key]. Same note as for __getitem__. - - -Special methods for sequence types ----------------------------------- - -__getslice__(self, i, j) --> sequence - -Used to implement self[i:j]. Note that missing i or j are replaced by -0 or len(self), respectively, and len(self) has been added to negative -i or j. - -__setslice__(self, i, j, sequence) - -Used to implement self[i:j] = value. Same note as for __getslice__. - -__delslice__(self, i, j) - -Used to implement del self[i:j]. Same note as for __getslice__. - - -Special methods for numeric types ---------------------------------- - -__add__, __sub__, __mul__, __div__, __mod__, __divmod__, __pow__, -__lshift__, __rshift__, __and__, __xor__, __or__ - -Used to implement the binary arithmetic operations (divmod and pow are -called by built-in functions). All have the call pattern -func(self, other) --> number. - -__neg__, __pos__, __abs__, __invert__ - -Used to implement the unary arithmetic operations (-, +, abs and ~). -All have the call pattern func(self) --> number. - -__nonzero__(self) --> int - -Used to implement boolean testing. An alternative name for this -method is __len__. - -__coerce__(self, other) --> (self1, other1) or None - -Used to implement "mixed-mode" numeric arithmetic. Either return a -tuple containing self and other converted to some common type, or None -if no way of conversion is known. When the common type would be the -type of other, it is sufficient to return None, since the interpreter -will also ask the other object to attempt a coercion (but sometimes, -if the implementation of the other type cannot be changed, it is -useful to do the conversion to the other type here). - -__int__(self) --> int -__long__(self) --> long -__float__(self) --> float - -Used to implement the built-in functions int(), long() and float(). - - -Notes ------ - -Except for __repr__ and __cmp__, when no appropriate method is -defined, attempts to execute the operation raise an exception. For -__repr__ and __cmp__, the traditional interpretations are used -in this case. -- cgit v0.12