[Tutor] Scope and elegance revisited

James Newton jnewton at fuelindustries.com
Wed Jan 9 22:28:33 CET 2008


Kent Johnson wrote: 
>> To give you the context: my application allows you to select a skin
for
>> the user interface.  I want to set the access path to the skin folder
as
>> a class variable, so that all instances of that class use images from
>> the appropriate folder.  The access path will be read in from a
>> preferences file before any instances of the class are created.

> Why do you have multiple instances of the class? You might be
interested 
> in the Borg pattern:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531

Hi Kent,

Thanks for your suggestion.

The folder in question contains images for counters for a board game.
Each player instance will use a separate counter image, but all counter
images will be chosen from the same folder.

It looks as if the Borg pattern would make all players use the same
counter image.

Or am I misunderstanding something?

James


More information about the Tutor mailing list