On 1/3/07, meelab <[EMAIL PROTECTED]> wrote:
> I am looking for a way to create a "static object" or a "static class" -
> terms might be inappropriate - having for instance:

An example will speak better than me:

class Card(object):
    __cards = {}

    def __init__(self, number, suit):
        self.number, self.suit = number, suit

    def __new__(cls, number, suit):
        try:
            return cls.__cards[(number, suit)]
        except KeyError:
            obj = object.__new__(cls, number, suit)
            cls.__cartas[(number, suit)] = obj
            return obj


-- 
Felipe.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to