Re: sys.modules

2019-02-21 Thread Terry Reedy
On 2/21/2019 11:40 AM, ast wrote: Hello Is it normal to have 151 entries in dictionary sys.modules just after starting IDLE or something goes wrong ? The is the right number. When Python starts, it imports around 50 modules. When it runs IDLE, most of idlelib modules are imported, plus

Re: sys.modules

2019-02-21 Thread DL Neil
Hello, On 22/02/19 5:40 AM, ast wrote: Is it normal to have 151 entries in dictionary sys.modules just after starting IDLE or something goes wrong ? >>> import sys >>> len(sys.modules) 151 I don't use Idle. Written in python, doesn't it require various packages

Re: sys.modules

2019-02-21 Thread Chris Angelico
On Fri, Feb 22, 2019 at 6:03 AM Chris Warrick wrote: > > On Thu, 21 Feb 2019 at 18:57, ast wrote: > > > > Hello > > > > Is it normal to have 151 entries in dictionary sys.modules > > just after starting IDLE or something goes wrong ? > > > >

Re: sys.modules

2019-02-21 Thread Chris Warrick
On Thu, 21 Feb 2019 at 18:57, ast wrote: > > Hello > > Is it normal to have 151 entries in dictionary sys.modules > just after starting IDLE or something goes wrong ? > > >>> import sys > >>> len(sys.modules) > 151 > > Most of common modules

sys.modules

2019-02-21 Thread ast
Hello Is it normal to have 151 entries in dictionary sys.modules just after starting IDLE or something goes wrong ? >>> import sys >>> len(sys.modules) 151 Most of common modules seems to be already there, os, itertools, random .... I thought that sys.modules was contain

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 1:29 PM, Emile van Sebille wrote: > On 2/15/2011 10:19 AM Chris Rebert said... >> On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas >>  wrote: >>> I have the following situation. In a big project that involves many >>> dependencies (and sadly some sys.module hacks) we have a b

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread python
Jorge, It's been a while since I felt the need to use a Python debugger, but I could swear that most (all?) Python debuggers allow you to watch a specific variable. Check out the debuggers on the following page: http://wiki.python.org/moin/PythonDebuggers Malcolm -- http://mail.python.org/mailm

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Mel
Emile van Sebille wrote: > Out of curiosity, if it's immutable, what approach might you try to > capture/trace reassignment? I've got a toy tracer that breaks with > simple assignment: AFAIK you'd have to replace the namespace dictionaries with dictionary-like things that would react to rebindi

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Emile van Sebille
On 2/15/2011 10:19 AM Chris Rebert said... On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas wrote: Hello, I have the following situation. In a big project that involves many dependencies (and sadly some sys.module hacks) we have a bug, and it will really help if i could monitor all changes made t

Re: How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Chris Rebert
On Tue, Feb 15, 2011 at 7:17 AM, Jorge Vargas wrote: > Hello, > > I have the following situation. In a big project that involves many > dependencies (and sadly some sys.module hacks) we have a bug, and it > will really help if i could monitor all changes made to that variable. > Is there a way to

How to inspect a variable (sys.modules) for changes in the execution of a program?

2011-02-15 Thread Jorge Vargas
Hello, I have the following situation. In a big project that involves many dependencies (and sadly some sys.module hacks) we have a bug, and it will really help if i could monitor all changes made to that variable. Is there a way to trace those changes ? -- http://mail.python.org/mailman/listinfo

Re: Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Steven D'Aprano
On Thu, 06 Aug 2009 20:01:42 +0200, Jean-Michel Pichavant wrote: > > I'm completely perplexed by this behaviour. sys.modules() seems to be > > a regular dict, at least according to type(), and yet assigning to an > > item of it seems to have unexpected, and rat

Re: Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: Given this module: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] sys.modules[__name__] = 123 print "After:" print " __name__ =", __

Unexpected side-effects of assigning to sys.modules[__name__]

2009-08-06 Thread Steven D'Aprano
Given this module: #funny.py import sys print "Before:" print " __name__ =", __name__ print " sys.modules[__name__] =", sys.modules[__name__] sys.modules[__name__] = 123 print "After:" print " __name__ =", __name__ print " sys =", sy

Re: sys.modules and __main__ obscureness

2006-07-16 Thread K.S.Sreeram
Fuzzyman wrote: > That was a quick response. :-) > > Thanks very much. Sigh.. When I'm drowning in arcane win32 c++ crap, I tend to jump on anything interesting on python-list. It feels like a breath of fresh air! [sreeram;] signature.asc Description: OpenPGP digital signature -- http://mail

Re: sys.modules and __main__ obscureness

2006-07-16 Thread Fuzzyman
ference to the existing module, > before overwriting with the new module. > > sys.blahblah = sys.modules['__main__'] > sys.modules['__main__'] = module > > [sreeram;] That was a quick response. :-) Thanks very much. Fuzzyman http://www.voidspace.org.uk/python/index.shtml &g

Re: sys.modules and __main__ obscureness

2006-07-16 Thread K.S.Sreeram
module object gets deleted along with its globals 'module' and 'namespace'. The code keeps working because the codeobject is retained by the interpreter. To make it work, simply retain a reference to the existing module, before overwriting with the new module. sys.blahbla

sys.modules and __main__ obscureness

2006-07-16 Thread Fuzzyman
') namespace = module.__dict__ namespace['__name__'] = '__main__' # next put things into the names # e.g. : namespace['variable'] = 3 sys.modules['__main__'] = module print module print namespace import __main__ print __main__.__dict__['variable'