proto-PEPs: __bind__ and __return__?

Michael Gilfix mgilfix at eecs.tufts.edu
Mon May 13 07:03:31 EDT 2002


  Isn't this kinda what coerce is supposed to accomplish?  While
I've never had a use for it and as I understand it, Guido wants it
removed, it seems that it's job is to try and make an object into an
appropriate type and would act just as below.

  However, this just seems to switch responsibilities. Rather than
having the target object know how to mutate itself or whether it can
mutate itself, the source object checks whether the target is worthy
of its binding. Hmm. It does seem more useful this way though because
an object could now be in an unbound state...

                -- Mike

On Mon, May 13 @ 17:07, Delaney, Timothy wrote:
> >  >>> class ConstrainType(object):
> >  ... 	def __bind__(self,target):
> >  ...		if unbound('self') or isinstance(target,self.__class__):
> >  ...			self=target
> >  ...		else:
> >  ...			raise ValueError, 'Type Constraint Violated'
> 
> class ConstrainType(object):
>     def __bind__(self,target):
>         if isinstance(target,self.__class__):
>             return target
>         else:
>             raise ValueError, 'Type Constraint Violated'

-- 
Michael Gilfix
mgilfix at eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html





More information about the Python-list mailing list