pipehappy wrote:

> Hello everyone:
> 
> Is there a way to check the type when do assignment?
> 
> if I write:
> ab = bc
> and want to make sure the return value of isinstance(bc, klass) is True
> or I will raise
> a exception.

In general, not doable. The assignment operator is not overloadable.

Only if you use assignments of the form

a.foo = bar

you could overwrite the __setattribute__-method to achieve what you want. 


Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to