Simple Question: simulation of primitive data types

Thomas Weholt thomas at cintra.no
Sat Apr 21 12:03:00 EDT 2001


I got a class like this:

class myclass:
    def __init__(self, val):
        self.val = val

# create an instance
x = myclass(1)

I want the statement 'print x' to result in the printing of '1' on the
screen, not using __str__ or __repr__, but returning the actual value of
self.val each time the instance is called.

I cannot remember how to implement this. Any hints?

Thomas





More information about the Python-list mailing list