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


Groups > comp.lang.python > #72949

Re:How to use imported function to get current globals

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'static': 0.04; 'modify': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'subject:How': 0.10; 'def': 0.12; 'wrote': 0.14; 'crude': 0.16; 'debugger,': 0.16; "module's": 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script?': 0.16; 'language': 0.16; 'module': 0.19; 'trying': 0.19; 'import': 0.22; 'print': 0.22; 'header:X-Complaints-To:1': 0.27; 'said,': 0.30; 'code': 0.31; 'probably': 0.32; 'could': 0.34; 'connection': 0.35; 'really': 0.36; 'so,': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'track': 0.38; 'bad': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'here': 0.66; 'subject:get': 0.81; 'snapshot': 0.84; 'subject::': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re:How to use imported function to get current globals
Date Sat, 7 Jun 2014 21:24:08 -0500 (CDT)
Organization news.gmane.org
References <602B90F0-E7FE-4887-ADA1-981FD4179EC7@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-71-97-198-161.hstntx.dsl-w.verizon.net
X-Newsreader PiaoHong.NewsGroup.Client.VIP:1.53
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10872.1402194206.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1402194206 news.xs4all.nl 2903 [2001:888:2000:d::a6]:49332
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72949

Show key headers only | View raw


1989lzhh <1989lzhh@gmail.com> Wrote in message:
> Here is the code
> m1.py
> def f():
>     print globals()
> 
> m2.py
> from m1 import f
> f()# how to get current module's globals?
> 

As others have said, it's probably a bad idea.  I can think of 3
 reasons to try: teacher said so, writing a debugger, 
 transliterating code from a crude language into python.

Could you elaborate on what you really want? Which of those two
 modules is your main script? Which code in which module is trying
 to get which module's globals?  And is the connection static or
 dynamic? And do you want a snapshot of them, or to be able to
 modify and track changes? 




-- 
DaveA

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


Thread

Re:How to use imported function to get current globals Dave Angel <davea@davea.name> - 2014-06-07 21:24 -0500

csiph-web