擅长:python、mysql、java
<blockquote>
<p>one of my cases in the function requires me to know if it is the "original" function call, in which case the files have no parent node</p>
</blockquote>
<p>这似乎是一个奇怪的情况,对于特定的功能来说工作太多了。你必须建造这棵树-为什么你要知道它附着在哪里?为什么不直接构造你负责的节点并返回它们呢?在</p>
<pre><code>def make_tree(path):
return [
make_tree(os.path.join(path, element))
for element in get_elements(path)]
</code></pre>
<p>当你收到那棵树的时候,再去走走?在</p>
<p>如果您真的想集成它,只需传递父对象:</p>
^{pr2}$