Philippe C. Martin wrote:
Hi,
After all of you answers, I though I had it straight, yet .
This is what I am doing:
class SC_ISO_7816:
__m_loaded = None
..
def __init__(self):
if SC_ISO_7816.__m_loaded == None:
SC_ISO_7816.__m_loaded = True
print 'LOADING'
>Well, from the looks of things, you don't seem to understand the
>basic idea of instances and instance attributes. There is a key
>difference between SC_ISO_67816.__m_loaded and self.SW1_DICT,
>and that is that the former one is seen by *all instances*, while
>the latter is an attribute in *only
Philippe C. Martin wrote:
class SC_ISO_7816:
__m_loaded = None
Please don't use tabs in code you post here. Many newsreaders
have trouble displaying them, and make the code look like it
does above (i.e. no indentation at all) which makes it hard to
understand.
..
def __init__(self):
Hi,
After all of you answers, I though I had it straight, yet .
This is what I am doing:
class SC_ISO_7816:
__m_loaded = None
..
def __init__(self):
"""
"""
if SC_ISO_7816.__m_loaded == None:
SC_ISO_7816.__m_loaded = True
print 'LOAD
Philippe C. Martin wrote:
Thank you all for your answers, I guess I would not have made Python 101:-)
As far as I was concerned, importing a module twice would have resulted in
loading the file twice.
Background on that: importing the module the first time causes the
code in it to be executed (i.
Thank you all for your answers, I guess I would not have made Python 101:-)
As far as I was concerned, importing a module twice would have resulted in
loading the file twice.
Regards,
Philippe
--
*
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
*
You're looking for the Singleton pattern to ensure that only one
instance of your class is instantiated at a time. There's a particularly
useful discussion about this at:
http://c2.com/cgi/wiki?PythonSingleton
I suggest you try the different methods out and pick the one best suited
to your situ
Am Tue, 07 Dec 2004 09:25:57 -0600 schrieb Philippe C. Martin:
> This is a basic question I'm sure but I do not know wether to use
> __builtin__,
> global, or a static method:
>
> I have a very large XML file that I load into dictionnaries defined in a
> class
> located in a module that is i
Philippe C. Martin wrote:
> I have a very large XML file that I load into dictionnaries defined in a
> class
> located in a module that is imported in many places.
>
> Since the loading process is very slow, I would like the file not to be
> loaded
> on import or class instantiation, but only
This is a basic question I'm sure but I do not know wether to use __builtin__,
global, or a static method:
I have a very large XML file that I load into dictionnaries defined in a class
located in a module that is imported in many places.
Since the loading process is very slow, I would like th
10 matches
Mail list logo