Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python Global Constant

Reply
Thread Tools

Re: Python Global Constant

 
 
Jp Calderone
Guest
Posts: n/a
 
      07-09-2003
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"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
Understanding How To Use #ifdef Constant #define Constant Sequence In Multible Files Christopher M. Lusardi C++ 1 09-02-2004 07:43 AM
Python Global Constant Krisztian Kepes Python 9 07-12-2003 09:53 PM
RE: Python Global Constant Michael Chermside Python 0 07-09-2003 12:48 PM



Advertisments