On Tue, Jun 14, 2011 at 7:33 PM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > > I have never seen code that needs this, and can't imagine why the above > would be a good design for a module. Is there real code online somewhere > that we can see which serves as a real example for your use case? >
Unfortunately not. Most of this line of thinking is the result of looking at import functionality in different ways, including with regards to the problem of modules getting imported twice (once as __main__). I've been doing work on multi-file modules, custom module objects, and custom import hooks lately, so I have been exploring a lot of the import related features. The situation came up where I was trying to actually apply some of that across a large package. The use case I originally gave is the real-life one that got me thinking about module flow control statements. However, the situation that led me there is not particularly wide-spread. Keep in mind that initially I was looking to see if there was something like return or break for modules, and not asking that they be added. That "expensive module stuff" example I gave was purely hypothetical, and I haven't really seen real code like it either. Like I said, my main motivation is to reduce my levels of indentation somewhat. I was trying to see if I could apply a pattern I use in functions and loops to modules. Things like "I have never seen..." are really helpful to hear, by the way, so thanks! -eric > -- > \ “There is no reason anyone would want a computer in their | > `\ home.” —Ken Olson, president, chairman and founder of Digital | > _o__) Equipment Corp., 1977 | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list