〆 os.path [python os module]

Don’t put off until tomorrow what you can do today.

How to use os.path: python模块之os模块探究。

[探究版本] python 3.7.0

importlib

关于python里的导包路径等等一说,以前一直没有一个清晰的认识,就只知道是单纯的给文件夹里增加一个空的文件:init.py

而基于这种不求甚解的做法,初期帮助了我很快胜任的工作,emmm,姑且算胜任吧。但是很快,我就发现,不理解底层,成为了我的一大瓶颈,于是,突然惊醒,开始抱着极客的态度,开始了深入的记录。

基于我使用的python3.7里,通过api查询path得到一个新的包,importlib,是python3.1开始新增加的东西,具体是什么,我们先来看一看。

话不多说,先上源码:importlib

简介

The purpose of the importlib package is two-fold. One is to provide the implementation of the import statement (and thus, by extension, the import() function) in Python source code. This provides an implementation of import which is portable to any Python interpreter. This also provides an implementation which is easier to comprehend than one implemented in a programming language other than Python.

Two, the components to implement import are exposed in this package, making it easier for users to create their own custom objects (known generically as an importer) to participate in the import process.

importlib的用途主要有两个方面。

  • 在python的源代码里(由此,通过对 import 模块的扩展),提供了一个导入清单的实现。
    对于任何python解释器,本库提供了更便捷的导入实现。
    它也提供了一个比用Python以外的编程语言实现更容易理解的实现。
  • 在同一个包里的组件的导入实现更加的显式,(通常被用来创建一个导入文件)
    用户可以将自己创建的文件更容易的导入到进程里。
真孒今将命


此致: 敬礼!

送赵法师还蜀因名山奠简

作者: 李隆基

摘自: 《全唐诗》

道家奠灵简, 自昔仰神仙

真孒今将命, 苍生福可传

江山寻故国, 城郭信依然

二室遥相望, 云回洞里天

座右铭: 进化是形成我们的身体形状和我们内在本能的主要力量, 他赋予我们大脑和学习机制,使我们可以根据经验实现自我更新。我们还需要终生学习,以改变我们的行为,从而适应包括进化论还不能预测的和可预测的各种环境。
Evolution is the major force that defines our bodily shape as well as our built-in instincts and reflexes. We also learn to change our behavior during our lifetime. This helps us cope with changes in the environment that cannot be predicted by evolution. Organisms that have a short life in a well-defined environment may have all their behavior built-in, but instead of hardwiring into us all sorts of behavior for any circumstance that we could encounter in our life, evolution gave us a large brain and a mechanism to learn, such that we could update ourselves with experience and adapt to different environments.