[Tutor] importing constants
Bob Gailer
ramrom@earthling.net
Mon Feb 10 17:11:13 2003
--=======16231CB7=======
Content-Type: text/plain; x-avg-checked=avg-ok-1B473DD2; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit
At 06:42 PM 2/9/2003 -0500, R. Alan Monroe wrote:
>I have a project consisting of a main file and two modules. If I want
>to set up a new third module file establishing some constants, is it
>safe to re-import it multiple times, once in each file and module?
Yes
>Are there any side-effects to doing that?
No
Suggestion: make "constant" names upper case e;g; IDLE = 1. This helps
later when reading code to remind you that IDLE is intended to be constant.
If you
import constants
then you must prefix the module name to each constant:
constants.IDLE
OTOH if you
from constants import *
then just use the constant name.
Bob Gailer
mailto:ramrom@earthling.net
303 442 2625
--=======16231CB7=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-1B473DD2
Content-Disposition: inline
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.445 / Virus Database: 250 - Release Date: 1/21/2003
--=======16231CB7=======--