[Tutor] How to generate instance names?

Alan Gauld alan.gauld at freenet.co.uk
Tue Nov 9 05:41:26 CET 2004

> I am new to object-oriented programming, and have a basic question.
> How can I generate an object name when creating an instance of a
> class, rather than hard-coding the name at creation?

This is nearly always a bad idea, it's better to use a dictionary.
See my tutorial OOP topic for an example of this.

There was also an extended thread on this a few weeks ago
(and indeed almost every month! ;-)

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list