Global object

Discussion in 'Python' started by Ghido, Nov 22, 2006.

  1. Ghido

    Ghido Guest

    Hi all, i need to save in an object some variable for use in other
    parts of my software. it's possibile without create an istance of this
    class in every file? if yes how?
    thanks a lot

    Ghido
    Ghido, Nov 22, 2006
    #1
    1. Advertising

  2. Ghido wrote:
    > Hi all, i need to save in an object some variable for use in other
    > parts of my software. it's possibile without create an istance of this
    > class in every file? if yes how?


    Create a module, say, ``config``. Then to save your object, you use
    something like::

    import config
    config.value = value_to_save

    Now if you want to access it from other parts of your program, simply
    write::

    import config
    do_something_with(config.value)



    STeVe
    Steven Bethard, Nov 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    1
    Views:
    777
    Alvin Bruney
    Jul 29, 2003
  2. Wayne
    Replies:
    2
    Views:
    467
    Wayne
    Nov 11, 2003
  3. Daniel Bass
    Replies:
    2
    Views:
    6,870
    Daniel Bass
    Dec 31, 2003
  4. 2obvious

    no global constants in global.asax?

    2obvious, Sep 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,815
  5. User1014
    Replies:
    3
    Views:
    187
    Richard Cornford
    Dec 1, 2006
Loading...

Share This Page