Hi there I’m trying to create a small tool that will create child directory’s within the Root directory Root Dir(python) And child Dir(DS, WEB, Flask, Learn) stuff like that At starting I have done it statically Here is the Code Then I decided to do it dynamically By using two lists just like before but thing’s don’t go well Here
Tag: directory
How do I run another file in python?
So I know how to write in a file or read a file but how do I RUN another file? for example in a file I have this: a = 1 print(a) How do I run this using another file? Answer using subprocess standard lib or using os standard lib or extract python code from the file and run it
Search word in word documents and print out the file name that contains that word?
Hey so I am new to Python and I wanted to make a script that retrieves the file name from a list of docx documents in a large directory if a file contains a certain word inside the word document. Here is my code below so far My thought process is to convert all these docx documents to txt files
Issue with folder path in tkinter (python)
I am having an issue of finding the bug in my code in relation to the folder path using filedialog. I have the following code The following error shows up: Answer To use you have to first create global doesn’t create variable but it is only used in function to inform this function to use external/global variable when you use
How to set PIPENV_VENV_IN_PROJECT on per-project basis
I want pipenv to create its virtualenv in $PROJECTDIR/.venv automatically for everyone who checks out the project. So far, I see only the following options working, none of which is satisfying: Ask users to set PIPENV_VENV_IN_PROJECT=1 globally, forcing my project preferences on each of their other projects. Ask users to always invoke pipenv via “PIPENV_VENV_IN_PROJECT=1 pipenv” when inside my project,
How to rename a virtualenv in Python?
I misspelled the name of the virtualenv while initializing it using: I actually intended to create the environment with the name venv. Having tried to rename the vnev folder to venv, I find that this doesn’t provide much help. The name of the activate environment still renames the old vnev. I would like to know how to go about renaming
How to know the folder size in a zipfile
I know that you can get the size in bytes of a file in a ZIP file using the .file_size method But is there any what I can get the size of a folder instead? Ex: Answer
Second newest file
I need the second newest file. In this thread the newest is found: Python get most recent file in a directory with certain extension which uses this construct: However, how can I get not the min or max but the second element? Answer I think this can be a suitable solution: So basically glob.iglob(‘*.log’) is just an array (to be
How do I find directory of the Python running script from inside the script?
How do I find the directory of the running Python script from inside Python [3.3]? I have tried what was suggested at: How can I find script’s directory? , but I get “Invalid syntax” and directed to “os” (And I did import os). The closest I have got to the answer is: sys.argv[0], but that still includes the file name,
Extract a part of the filepath (a directory) in Python
I need to extract the name of the parent directory of a certain path. This is what it looks like: I would like to extract directory_i_need. Answer And you can continue doing this as many times as necessary… Edit: from os.path, you can use either os.path.split or os.path.basename: