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...
--
http://mail.python.org
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 under
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 = {}
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()
s
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:
>
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 = Stati
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
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 staticObjec