Importing is partially working...

Chris Angelico rosuav at gmail.com
Mon Aug 10 12:08:54 EDT 2015


On Tue, Aug 11, 2015 at 1:48 AM, MRAB <python at mrabarnett.plus.com> wrote:
>> You're almost there! But in Python, you don't import something from a
>> specific file - you import from a module, and the Python interpreter
>> is free to locate that file anywhere that it can. It might be
>> implemented in C, and be stored in Functions.so (on Unix-like systems)
>> or Functions.dll (on Windows); it might be precompiled and loaded from
>> Functions.pyc; it might come from a zip file, or some other form of
>> special import source. So all you say is:
>>
> On Windows, the extension for Python extension DLLs is ".pyd".

Or that. I haven't built any Python extensions in, well, ever, and
haven't even deployed other people's in years, so I'm a bit rusty.
Anyway, point is you don't have to care where it actually comes from.

The one thing that I do kinda miss in Python is an easy way to "shadow
and pull in the original" - to create something earlier in the search
path, but then have that file get a reference to "the module that
would have been loaded if I hadn't been here". It's not often you want
it, but quite frankly, I don't know how I'd spell it at all. There
probably is a way, but I've no idea what it is...

ChrisA



More information about the Python-list mailing list