static object
Felipe Almeida Lessa
felipe.lessa at gmail.com
Wed Jan 3 19:36:20 EST 2007
More information about the Python-list mailing list
Wed Jan 3 19:36:20 EST 2007
- Previous message (by thread): static object
- Next message (by thread): static object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 1/3/07, meelab <meelab at free.fr> 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.
- Previous message (by thread): static object
- Next message (by thread): static object
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list