[Python-ideas] PEP for executing a module in a package containing relative imports (original) (raw)
Brett Cannon brett at python.org
Sun Apr 22 20:39:01 CEST 2007
- Previous message: [Python-ideas] PEP for executing a module in a package containing relative imports
- Next message: [Python-ideas] PEP for executing a module in a package containing relative imports
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4/22/07, Jim Jewett <jimjjewett at gmail.com> wrote:
On 4/21/07, Brett Cannon <brett at python.org> wrote: > On 4/21/07, Josiah Carlson <jcarlson at uci.edu> wrote:
> > After reading other posts in the thread, I'm going to put my support > > into the sys.main variant. It has all of the benefits of the builtin name > > == main, with none of the drawbacks (no builtin!), and only a slight > > annoyance of 'import sys', which is more or less free. > Yeah, I am starting to like it as well. Steven and Jim, what do you think? Better than adding a builtin. I'm not sure I like the idea of another semi-random object in sys either, though. (1) One of the motivations was importing. It looks like file already has sufficient information. I understand that relying on it (or on package?) seems a bit hacky, but is it really worse than adding something?
Yes, because you have no guarantee file will in any way be unique or even defined (look at 'sys'). It's up to the loader to set file and it can do whatever it wants. This doesn't happen with name since it is rather clear what that should be no matter where the module was loaded from (unless it was a Python file specified at the command line in some random directory).
-Brett
- Previous message: [Python-ideas] PEP for executing a module in a package containing relative imports
- Next message: [Python-ideas] PEP for executing a module in a package containing relative imports
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]