Re: Python Global Constant

Discussion in 'Python' started by Jp Calderone, Jul 9, 2003.

  1. Jp Calderone

    Jp Calderone Guest

    On Wed, Jul 09, 2003 at 09:49:15AM +0200, Krisztian Kepes wrote:
    > Hi !
    >
    > I want to create an module and I want to use some Global Constant in it.
    > How to I create an global constant in module what is accessable in from other modules ?


    Python does not have constant variables. If you remove the "const " on
    each of the two lines in your dirs module and use the equality test operator
    ("==") instead of the assignment operator ("="), your code should work.

    As a convention, variables which the author intends not to be changed are
    often spelled entirely in capitals, e.g., CONST_DOWN.

    >
    > like this example:
    >
    > *** module dirs ***
    > const Const_Up=1
    > const Const_Down=1
    >
    > *** module any ***
    > import dirs;
    > def CheckDir(Dir):
    > if Dir=dirs.Const_Up: xxx
    >


    Jp

    --
    "I quite agree with you," said the Duchess; "and the moral of
    that is -- Be what you would seem to be' -- or, if you'd like it put
    more simply -- Never imagine yourself not to be otherwise than what it
    might appear to others that what you were or might have been was not
    otherwise than what you had been would have appeared to them to be
    otherwise.'" -- Lewis Carrol, "Alice in Wonderland"
     
    Jp Calderone, Jul 9, 2003
    #1
    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. Christopher M. Lusardi
    Replies:
    1
    Views:
    4,126
  2. Martin Magnusson
    Replies:
    2
    Views:
    525
    John Harrison
    Oct 8, 2004
  3. Tor Erik Soenvisen
    Replies:
    14
    Views:
    584
    Tim Roberts
    Nov 23, 2006
  4. Replies:
    4
    Views:
    352
    Keith Thompson
    Dec 14, 2006
  5. Replies:
    13
    Views:
    13,003
    Kai-Uwe Bux
    Jan 22, 2007
Loading...

Share This Page