Coder Social home page Coder Social logo

python-package-test's Introduction

python 的package以及目录组织相关问题

├── a
│   ├── __init__.py
│   ├── module_a.py
├── b
│   ├── __init__.py
│   ├── module_b.py
├── __init__.py
├── README.md
└── test.py

在这个例子里面,a,b 互相不可见。直接运行module_a不能使用module_b的函数,即使使用了相对导入也没有用

我认为这是合理的,package 直接确实不能直接互相调用,毕竟我们不会直接运行module_a,这样不合理,更合理的方案是在project层面使用两个package,代码不用修改,因为站在test的角度,可以看见两个package,此时通过调用module_a简洁调用module_b的行为是被支持的,我猜测原因可能是python作为脚本语言特性,相当于换一个位置加载脚本,所以能正确运行

参考

  1. 【python】引用各种路径下的package和module

python-package-test's People

Contributors

gannerfreer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.