Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8301

Re: Project-wide variable...

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Project-wide variable...
Followup-To comp.lang.python
Date Thu, 23 Jun 2011 16:42:58 +0200
Organization None
Lines 31
Message-ID <itvjdi$a3n$1@solani.org> (permalink)
References <7c6cf5e3-8ba0-45c8-86f8-bf3fc5fa2422@v11g2000prn.googlegroups.com> <mailman.321.1308837590.1164.python-list@python.org> <2cc8ba29-b669-4f1c-aa42-2e518402917c@p13g2000yqh.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace solani.org 1308840178 10359 eJwFwYEBgDAIA7CXhNEq50AZ/59ggkOj3iAYWGygkMdvjtel7NlSa1VfV0fOZJtrNiFjV/44JhJ6 (23 Jun 2011 14:42:58 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 23 Jun 2011 14:42:58 +0000 (UTC)
X-User-ID eJwNysEBwCAIA8CVQEiQcRRh/xHaex+Mygon6BhMqZibR4OYQWo/lQwl24qy++D40O+5uXpnKTzW/6LeQOMDNJoUtA==
Cancel-Lock sha1:ZI92k5wNV5fcSL7/Q0zevW5j72k=
X-NNTP-Posting-Host eJwFwQcBwDAMAzBKy7HbwsnlD2ESjMI6TtCx2A89vmE632a6ZRESksI+zbvA1RM4O7w2jYpk7fOkfSojj8/NKxWI1N4f6dYaTQ==
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8301

Followups directed to: comp.lang.python

Show key headers only | View raw


Gnarlodious wrote:

> On Jun 23, 7:59 am, Noah Hall wrote:
>> >>>from a import x
> 
> I'm doing that:
> import Module.Data as Data

from Module import Data

There, you saved three more characters .

> However I end up doing it in every submodule, so it seems a little
> redundant. I wish I could load the variable in the parent program and
> have it be available in all submodules. Am I missing something?

You can modify the builtin namespace:

$ cat module.py
print data
$ cat main.py
import __builtin__
__builtin__.data = 42

import module
$ python main.py
42
$

But I don't think it's a good idea. Remember that "explicit is better than 
implicit".

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 06:41 -0700
  Re: Project-wide variable... Calvin Spealman <ironfroggy@gmail.com> - 2011-06-23 09:51 -0400
  Re: Project-wide variable... Noah Hall <enalicho@gmail.com> - 2011-06-23 14:59 +0100
    Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 07:09 -0700
      Re: Project-wide variable... Peter Otten <__peter__@web.de> - 2011-06-23 16:42 +0200
        Re: Project-wide variable... "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2011-06-23 08:20 -0700
        Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 10:48 -0700
      Re: Project-wide variable... Noah Hall <enalicho@gmail.com> - 2011-06-23 15:55 +0100
      Re: Project-wide variable... Terry Reedy <tjreedy@udel.edu> - 2011-06-23 14:10 -0400
        Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 19:01 -0700
          Re: Project-wide variable... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-24 02:11 +0000
            Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 20:49 -0700
              Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 21:01 -0700
                Re: Project-wide variable... alex23 <wuwei23@gmail.com> - 2011-06-23 21:04 -0700
              Re: Project-wide variable... Terry Reedy <tjreedy@udel.edu> - 2011-06-24 02:27 -0400
                Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-24 04:30 -0700
                Re: Project-wide variable... Terry Reedy <tjreedy@udel.edu> - 2011-06-24 17:19 -0400
  Re: Project-wide variable... Guillaume Martel-Genest <guillaumemg@gmail.com> - 2011-06-23 10:18 -0700
    Re: Project-wide variable... Noah Hall <enalicho@gmail.com> - 2011-06-23 18:42 +0100
      Re: Project-wide variable... Gnarlodious <gnarlodious@gmail.com> - 2011-06-23 11:01 -0700

csiph-web