instance name

Andrew Koenig ark at acm.org
Sat Apr 2 10:58:57 EST 2005


"max(01)*" <max2 at fisso.casa> wrote in message 
news:99z3e.1157607$35.42889387 at news4.tin.it...

> is there a way to define a class method which prints the instance name?

The term "the instance name" is misleading, because it assumes, without 
saying so explicitly, that every instance has a unique name.

In fact, there is no reason that an instance needs to have a name at all, or 
that it should have only one.

You gave this example:

    instance_1 = class_1()
    instance_1.myName()

but what if I did this instead?

    class_1().myName()

Or this?

    instance_1 = class_1()
    instance_2 = instance_1
    instance_2.myName()





More information about the Python-list mailing list