Adaptation and typecasting (was Re: [Python-Dev] replacing
'global')
Greg Ewing
greg at cosc.canterbury.ac.nz
Tue Oct 28 21:56:53 EST 2003
"Phillip J. Eby" <pje at telecommunity.com>:
> Given all this, I think I'm okay with saying that adapting from a mutable
> object to an immutable interface (e.g list->tuple) is an improper use of
> adaptation.
Expecting such an adaptation to somehow make the underlying
list unchangeable by any means would be unreasonable, I
think. I can't see any way of enforcing that other than by
making a copy, which goes agains the spirit of adaptation.
There still might be uses for it, though, without any
unchangeability guarantee, such as passing it to something
that requires a tuple and not just a sequence, but not
wanting the overhead of making a copy.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list