Ben Finney a écrit :
(snip)
The Singleton pattern does what you say here. Implementing a proper
Singleton in Python is complicated and hard to understand.
Really ? Using __new__ and a class attribute, it doesn't seem so
complicated - nor difficult to understand...
--
Dear All,
I am looking for a way to create a static object or a static class -
terms might be inappropriate - having for instance:
class StaticClass:
.
.
and then
staticObject1 = StaticClass()
staticObject2 = StaticClass()
so that staticObject1 and staticObject2 refers exactly
That looks like some kind of singleton. Why don't you use a module
instead of a class?
Another solution is to define your data as class attributes.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
meelab schrieb:
Dear All,
I am looking for a way to create a static object or a static class -
terms might be inappropriate - having for instance:
class StaticClass:
.
.
and then
staticObject1 = StaticClass()
staticObject2 = StaticClass()
so that staticObject1
In article [EMAIL PROTECTED],
meelab [EMAIL PROTECTED] wrote:
Dear All,
I am looking for a way to create a static object or a static class -
terms might be inappropriate - having for instance:
class StaticClass:
.
.
and then
staticObject1 = StaticClass()
staticObject2
At Wednesday 3/1/2007 19:38, meelab wrote:
I am looking for a way to create a static object or a static class -
terms might be inappropriate - having for instance:
class StaticClass:
.
.
and then
staticObject1 = StaticClass()
staticObject2 = StaticClass()
so that staticObject1
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
meelab [EMAIL PROTECTED] writes:
In other words, that is a class which would result in only 1 instance
always the same no matter how many times I will instantiate it.
The Singleton pattern does what you say here. Implementing a proper
Singleton in Python is complicated and hard to understand.
thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyDateTime_Check references static