Avoiding the __repr__ call or protecting an instance from evaluation URG. please
Emile van Sebille
emile at fenx.com
Sat Jan 27 13:55:24 EST 2001
You're probably passing the instance in a manner that repr
is invoked. Can you post a sample showing the problem?
Normal passing would be something like:
class test:
def __repr__(self):
return "class repr"
def func(a):
print type(a), a
t = test()
func(t)
HTH
--
Emile van Sebille
emile at fenx.com
-------------------
"Fernando Rodríguez" <spamers at must.die> wrote in message
news:db367t8ed4ktadbdmf71lgk1t8h3p3i4lk at 4ax.com...
> Hi!
>
> I have a class whose __repr__ method returns a string.
Whenever I pass
> an instance of this class to a function, what the function
gets is the result
> of __repr__. Most of the time this is OK, but under
certain circumstances I
> also need to make sure that a function receives an
instance of the class, and
> the the string that __repr__ returns.
>
> How can I do this? O:-)
>
> PS This is my __repr__ method:
> def __repr__( self ):
> return ",v" + str(self.tag) +", "
>
>
>
>
> //-----------------------------------------------
> // Fernando Rodriguez Romero
> //
> // frr at mindless dot com
> //------------------------------------------------
More information about the Python-list
mailing list