On Tue, Jul 13, 2010 at 7:47 AM, Fred Drake <fdrake at acm.org> wrote: > On Mon, Jul 12, 2010 at 5:42 PM, Michael Foord > <fuzzyman at voidspace.org.uk> wrote: >> I'm sure Brett will love this idea, but if it was impossible to reimport the >> script being executed as __main__ with a different name it would solve these >> problems. > > Indeed! And I'd be quite content with such a solution, since I > consider scripts and modules to be distinct. And here I've been busily blurring that distinction for years ;) (actually, the whole "name == '__main__'" idiom meant the distinction was already pretty blurry long before I got involved) I take it the concrete proposal here is if the filename of a new module matches either __main__.__file__ or __main__.__cached__, then that module should be ignored completely for import purposes allowing a module with the same name later on sys.path to be found? I'm not sure I like that, I'd be more inclined to just return the __main__ module in that case rather than letting the search continue further down sys.path (although I agree the current semantics of getting two copies of the same module under different names in this case are less than ideal). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4