directory-structure

How to merge folders in every subdirectory using python code?

How to merge folders in every subdirectory using python code? Question: my directory now.[1] I want to combine every Sub in every Folder so it should look something like this [2] [1]: https://i.stack.imgur.com/xz7FJ.png [2]: https://i.stack.imgur.com/scK48.png Asked By: mayuresh || Source Answers: You can iterate through all the files/dirs in a directory using os.walk(). We are …

Total answers: 1

Best directory structure for a repository with several python entry points and internal dependencies?

Best directory structure for a repository with several python entry points and internal dependencies? Question: I’m working on a project with the following directory structure: project/ package1/ module1.py module2.py package2/ module1.py module2.py main1.py main2.py main3.py … mainN.py where each mainX.py file is an executable Python script that imports modules from either package1, package2, or both. …

Total answers: 2

List directory tree structure in python from a list of path file

List directory tree structure in python from a list of path file Question: The question is intended to broaden the scope of a question already answered on stackoverflow by the topic "List directory tree structure in python?". The goal is to form a list of strings that visually represent a directory tree, with branchs. But …

Total answers: 3

How to install Python on a recent Windows computer in C:Program Files?

How to install Python on a recent Windows computer in C:Program Files? Question: I’m starting to get extremely FURIOUS with the latest Windows environments (Windows 10): I’ve just downloaded and installed Python, version 3.9. The installer proposed to install it under "C:Users…", I thought "No way, because if, for whatever reason, I remove this user, …

Total answers: 1

Where do I put my python files in the venv folder?

Where do I put my python files in the venv folder? Question: (Probably a noob question, but I didn’t find a solution after googling for 20 minutes.) I created a new pure Python project with PyCharm which yielded the following folder structure myproject └── venv ├── bin │   ├── activate │   ├── activate.csh │   ├── …

Total answers: 2

Python relative-import script two levels up

Python relative-import script two levels up Question: I’ve been struggling with imports in my package for the last hour. I’ve got a directory structure like so: main_package | | __init__.py | folder_1 | | __init__.py | | folder_2 | | | __init__.py | | | script_a.py | | | script_b.py | | folder_3 | | …

Total answers: 1

How to extract file from zip without maintaining directory structure in Python?

How to extract file from zip without maintaining directory structure in Python? Question: I’m trying to extract a specific file from a zip archive using python. In this case, extract an apk’s icon from the apk itself. I am currently using with zipfile.ZipFile(‘/path/to/my_file.apk’) as z: # extract /res/drawable/icon.png from apk to /temp/… z.extract(‘/res/drawable/icon.png’, ‘temp/’) which …

Total answers: 1

List directory tree structure in python?

List directory tree structure in python? Question: I know that we can use os.walk() to list all sub-directories or all files in a directory. However, I would like to list the full directory tree content: – Subdirectory 1: – file11 – file12 – Sub-sub-directory 11: – file111 – file112 – Subdirectory 2: – file21 – …

Total answers: 17

Yield in a recursive function

Yield in a recursive function Question: I am trying to do something to all the files under a given path. I don’t want to collect all the file names beforehand then do something with them, so I tried this: import os import stat def explore(p): s = ” list = os.listdir(p) for a in list: …

Total answers: 9