Label-Value (was: Re: Inheriting the @ sign from Ruby)

Aahz Maruch aahz at panix.com
Tue Dec 12 16:32:30 EST 2000


In article <r0pwvd51gga.fsf at black.cs.washington.edu>,
Daniel Wood  <daniel at cs.washington.edu> wrote:
>
>I'm talking about an *object* that is both an int and mutable.
>
>class MutableInt:
>	def __init__( self, default ):
>		self.value = default
>	def set( self, val ):
>		self.value = val
>	def get( self ):
>		return self.value
>	# And maybe
>	def __int__( self ):
>		return self.value
>
>My question is: am I confused if I think that this might be useful?
>And if it is useful then what's the most pythonic way to do this.
>(And if the best thing is a list of one element, why isn't that much
>more "hack" than "idiom"?)

This is useful and you've just used the most Pythonic mechanism.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

What if there were no rhetorical questions?  --Aahz



More information about the Python-list mailing list