How do I define a global constant...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SpreadTooThin

    #1

    How do I define a global constant...

    How do I define a constant that I can use in my script...
    For example lets say I have a file called constants.py and in there I
    have PI = 3.14

    in my test script I do:

    from constants import *

    How do I access PI later on?


    Pardon my newbie questions...

  • John Machin

    #2
    Re: How do I define a global constant...


    SpreadTooThin wrote:
    How do I define a constant that I can use in my script...
    For example lets say I have a file called constants.py and in there I
    have PI = 3.14
    >
    in my test script I do:
    >
    from constants import *
    >
    How do I access PI later on?
    Like this:

    inaccurate_esti mate_of_area = PI * radius ** 2 # :-)

    You may wish to have a look at the built-in math module:

    from math import *
    much_better_are a = pi * radius ** 2

    HTH,
    John

    Comment

    Working...