简体   繁体   English

不是包的python项目的结构

[英]Structure of a python project that is not a package

If you search over the internet about python project structures, you will find some articles about python package structure.如果您在互联网上搜索有关 python 项目结构的信息,您会找到一些关于 python 包结构的文章。 Based on it, What I want to know is if there is any kind of instructions for creating structure for python projects that isn't packages, that is, projects that the code is the end code it self?基于它,我想知道的是,是否有任何类型的说明可以为不是包的python项目创建结构,即代码本身就是最终代码的项目?

For example, I created a package that handles some requests of some specific endpoints.例如,我创建了一个包来处理某些特定端点的一些请求。 This package will serve the main code that will handle the data fetched by this package.此包将提供处理此包获取的数据的主要代码。 The main code is not a package, that is, it don't have classes and __init__ files, because in this software layer, there will be no necessity of code reuse.主代码不是包,也就是没有类和__init__文件,因为在这个软件层,就没有代码复用的必要了。 Instead, the main code relate straight to the end it self.相反,主要代码直接与它自身的结尾相关。

Is there any instructions for it?有什么说明吗?

It would be good to see the structure itself instead of reading the description of it - it can help visualize the problem and answer properly to your case 😉看到结构本身而不是阅读它的描述会很好 - 它可以帮助可视化问题并正确回答您的案例😉

projects that isn't packages, that is, projects that the code is the end code it self不是包的项目,也就是说,项目代码是它自己的最终代码

In general, I would say you should always structure your code!一般来说,我会说你应该总是构建你的代码! And by telling that, I mean exactly the work with the modules/packages.说到这里,我的意思是模块/包的工作。 It is needed mostly to sperate the responsibilities and to introduce things that can be reused.主要是为了分散职责和引入可以重用的东西。 It also gives the possibility to find things easier/faster instead of going through the unstructured tones of the code.它还提供了更容易/更快地找到事情的可能性,而不是通过代码的非结构化基调。

Of course, as I said, it is a general thought and as far as you are experienced you can experiment with the structure to find the best one for the project which you are working on.当然,正如我所说,这是一个普遍的想法,就您的经验而言,您可以对结构进行试验,以找到最适合您正在进行的项目的结构。 But without any structure, you won't survive in a bigger project (or the life will be harder than you want).但是没有任何结构,你将无法在更大的项目中生存(或者生活会比你想要的更艰难)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM