TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How the Python import system works

2 pointsby r4victoralmost 4 years ago

2 comments

r4victoralmost 4 years ago
Hi! This is part 11 of my Python behind the scenes series. I&#x27;ve been programming in Python for quite a while but didn&#x27;t really understand how the import system works: what modules and packages are exactly; what relative imports are relative to; what&#x27;s in sys.path and so on. My goal with this part was to answer all these questions. After you read it, you should be able to tell what exactly happens during the import process.<p>I welcome your feedback and questions. Thanks!
ksajalmost 4 years ago
These articles are quite good. Thanks for posting them.<p>I like the encyclopedic process of picking a topic, and digging in as deep as one can go. I had no idea there was so much going on with Python&#x27;s import system until now.<p>Having said that, I think you might have missed a swell feature: import xx as y.<p>I think most people use it just to simplify function names, but it&#x27;s especially important for people who create their own private libraries, which inevitably result in function name clashes down the line. I guess also if you tend to use a lot of similar libraries, like what often happens with networking or math.<p>Anyway, I&#x27;m just learning Python, so you gained at least one new reader here.
评论 #27841215 未加载