Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26757
| From | Roy Smith <roy@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: I thought I understood how import worked... |
| Date | 2012-08-08 09:12 -0400 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <roy-24E4AC.09124708082012@news.panix.com> (permalink) |
| References | <50211dba$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.3071.1344380066.4697.python-list@python.org> <87hasehvfu.fsf@benfinney.id.au> |
In article <87hasehvfu.fsf@benfinney.id.au>,
Ben Finney <ben+python@benfinney.id.au> wrote:
> Cameron Simpson <cs@zip.com.au> writes:
>
> > All of you are saying "two names for the same module", and variations
> > thereof. And that is why the doco confuses.
> >
> > I would expect less confusion if the above example were described as
> > _two_ modules, with the same source code.
>
> That's not true though, is it? It's the same module object with two
> different references, I thought.
Nope. I modified my test case to print out the id of the module:
('broken', <module 'broken' from
'/home/roy/play/import/foo/broken.pyc'>) 140608299115512
('foo.broken', <module 'foo.broken' from
'/home/roy/play/import/foo/broken.pyc'>) 140608299116232
> Also, even if what you say were true, “source code” implies the module
> was loaded from source code, when Python allows loading modules with no
> source code available.
This is true. In fact, when I first started chasing this down, one
import was finding the .py file, and the other the .pyc file (created
during the first import). I originally assumed that the .py/.pyc
distinction was the critical piece of the puzzle (and went down a
rathole exploring that).
Then I went down a different rathole when I noticed that one code path
was doing "import settings", while the other was doing
"__import__(module_name)", thinking import and __import__ were somehow
doing different things.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 09:18 -0400
Re: I thought I understood how import worked... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 13:52 +0000
Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 08:25 -0700
Re: I thought I understood how import worked... Paul Rubin <no.email@nospam.invalid> - 2012-08-07 08:53 -0700
Re: I thought I understood how import worked... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 17:54 +0000
Re: I thought I understood how import worked... Cameron Simpson <cs@zip.com.au> - 2012-08-08 08:47 +1000
Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 19:05 -0400
Re: I thought I understood how import worked... Ben Finney <ben+python@benfinney.id.au> - 2012-08-08 14:14 +1000
Re: I thought I understood how import worked... Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-08 08:40 +0200
Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-08 09:12 -0400
Re: I thought I understood how import worked... Cameron Simpson <cs@zip.com.au> - 2012-08-09 15:52 +1000
Re: I thought I understood how import worked... Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 23:55 +1000
Re: I thought I understood how import worked... Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-07 16:14 +0200
Re: I thought I understood how import worked... Roy Smith <roy@panix.com> - 2012-08-07 08:32 -0700
Re: I thought I understood how import worked... Terry Reedy <tjreedy@udel.edu> - 2012-08-07 13:15 -0400
Re: I thought I understood how import worked... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 15:10 +0100
Re: I thought I understood how import worked... Terry Reedy <tjreedy@udel.edu> - 2012-08-07 12:49 -0400
Re: I thought I understood how import worked... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 18:44 +0100
Re: I thought I understood how import worked... Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-08 10:47 +0200
csiph-web