ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> import-sig
import-sig
Re: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism.
by Fredrik Lundh other posts by this author
Nov 12 2001 5:05PM messages near this date
Re: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. | Re: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism.
James C. Ahlstrom wrote:
>  > Currently, os.py in a package masks the real one from
>  > anywhere inside the package. This would extend that to
>  
>  What???
>  
>  When Python starts, it imports site.py which imports os.py.
>  So os.py gets loaded, and won't normally get re-loaded.

a python system doesn't necessarily load site.py, but
nevermind...

>  So if os.py is in package1, it won't get loaded for "import os",
>  but it would get loaded for "import package1.os".  Are you saying
>  that "import package1.package2.os" will load package1/os.py?

no, but an "import os" from inside the "spam.py" module installed
as "package1.spam" will attempt to import "package1.os" before
it looks for "os" in the path.

consider this (somewhat simplified) directory structure:

    package1/__init__.py
    package1/spam.py
    package1/os.py

and this interpreter session:

$ python -vvS
Python 2.1.1
Type "copyright", "credits" or "license" for more information.
> >> import package1
import package1 # directory pythonware
# trying package1/__init__.py
# package1/__init__.pyc matches package1/__init__.py
import pythonware # precompiled from package1/__init__.pyc
> >> import package1.spam
# trying package1/spam.py
# package1/spam.pyc matches package1/spam.py
import pythonware.spam # precompiled from package1/spam.pyc
# trying package1/os.py
# package1/os.pyc matches package1/os.py
import pythonware.os # precompiled from package1/os.pyc

(note the last line)

>  I hope that "import os" will not load package1/os.py, will it?

depends on who's calling it.

</F> 


_______________________________________________
Import-sig mailing list
Import-sig@[...].org
http://mail.python.org/mailman/listinfo/import-sig
Thread:
eric
Prabhu Ramachandran
Prabhu Ramachandran
Prabhu Ramachandran
Gordon McMillan
James C. Ahlstrom
Barry A. Warsaw
Gordon McMillan
Toby Dickenson
Steve Holden
Barry A. Warsaw
Prabhu Ramachandran
Barry A. Warsaw
Fredrik Lundh
Barry A. Warsaw
Prabhu Ramachandran
Prabhu Ramachandran
Prabhu Ramachandran
Barry A. Warsaw
Michel Pelletier
Prabhu Ramachandran
Michel Pelletier
James C. Ahlstrom
Prabhu Ramachandran
Prabhu Ramachandran
Prabhu Ramachandran
eric
Prabhu Ramachandran
eric
Gordon McMillan
Toby Dickenson
M.-A. Lemburg
Barry A. Warsaw
Fredrik Lundh
Prabhu Ramachandran
Barry A. Warsaw
Michel Pelletier
Prabhu Ramachandran
James C. Ahlstrom
Gordon McMillan
Barry A. Warsaw
Prabhu Ramachandran
Prabhu Ramachandran
Barry A. Warsaw
Prabhu Ramachandran
James C. Ahlstrom
Prabhu Ramachandran
Jeremy Hylton
Prabhu Ramachandran
Jeremy Hylton
Prabhu Ramachandran
Jeremy Hylton
Prabhu Ramachandran
Prabhu Ramachandran
Greg Ward
Just van Rossum
Thomas Heller
Just van Rossum
Jeremy Hylton
Gordon McMillan
Gordon McMillan
Gordon McMillan
Prabhu Ramachandran
Jeremy Hylton
Prabhu Ramachandran
Prabhu Ramachandran
Jeremy Hylton
Prabhu Ramachandran
Jeremy Hylton
Jeremy Hylton
eric
Prabhu Ramachandran
Gordon McMillan
Prabhu Ramachandran
Gordon McMillan
Prabhu Ramachandran

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved