Using '__mul__' within a class

John J. Lee jjl at pobox.com
Sun Sep 25 16:28:07 CEST 2005


"Gerard Flanagan" <grflanagan at yahoo.co.uk> writes:
[...]
> class FibonacciMatrix:
[...]
>     def Copy( self ):
[...]

__copy__ would be a more standard name.  Then:

import copy
fm = FibonacciMatrix()
fm2 = copy.copy(fm)


I suppose you could also add:

__deepcopy__ = __copy__


in the body of the class definition.


John




More information about the Python-list mailing list