subdirectory

Getting a list of all subdirectories in the current directory

孤街浪徒 提交于 2019-11-25 23:38:47
问题 Is there a way to return a list of all the subdirectories in the current directory in Python? I know you can do this with files, but I need to get the list of directories instead. 回答1: Do you mean immediate subdirectories, or every directory right down the tree? Either way, you could use os.walk to do this: os.walk(directory) will yield a tuple for each subdirectory. Ths first entry in the 3-tuple is a directory name, so [x[0] for x in os.walk(directory)] should give you all of the

How do I clone a subdirectory only of a Git repository?

时间秒杀一切 提交于 2019-11-25 22:54:42
问题 I have my Git repository which, at the root, has two sub directories: /finisht /static When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so: svn co svn+ssh://admin@domain.com/home/admin/repos/finisht/static static Is there a way to do this with Git? 回答1: EDIT : As of Git 2.19, this is finally possible, as can be seen in this answer: https://stackoverflow.com/a/52269934/2988. Consider upvoting that answer. Note: in Git 2.19, only client

Import a file from a subdirectory?

♀尐吖头ヾ 提交于 2019-11-25 20:22:14
I have a file called tester.py , located on /project . /project has a subdirectory called lib , with a file called BoxTime.py : /project/tester.py /project/lib/BoxTime.py I want to import BoxTime from tester . I have tried this: import lib.BoxTime Which resulted: Traceback (most recent call last): File "./tester.py", line 3, in <module> import lib.BoxTime ImportError: No module named lib.BoxTime Any ideas how to import BoxTime from the subdirectory? EDIT The __init__.py was the problem, but don't forget to refer to BoxTime as lib.BoxTime , or use: import lib.BoxTime as BT ... BT.bt_function()