Python Forum
Thread Rating:
  • 3 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
making a directory
#1
i am given a string of a path and need to make a directory there unless one is already there.  so i might need to also make the parents.  is there a slick function/module to do this in python (without installing anything) or is my only easy option to do subprocess.call(['mkdir','-p',dirpath)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
os.makedirs does this
Reply
#3
(Mar-22-2017, 05:24 AM)buran Wrote: os.makedirs does this

i searched for this.  i did not know its name nor did i guess the right keywords.  thanks!  i need some better means to find python tools.  i was almost ready to write such a function.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Take a quick tour of os and os.path and look at the purpose of every method. After that you will know what you can do
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
if i read about too many things at once i forget enough about most of them to make that useless. i won't remember the function name or the particular words to describe it. this has happened before, do i know it is real. what i think i need to do is make a web page with all the nice things listed in a short form (one line each). that will be a lot of work.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
(Mar-23-2017, 02:52 AM)Skaperen Wrote: if i read about too many things at once i forget enough about most of them to make that useless.  i won't remember the function name or the particular words to describe it.  this has happened before, do i know it is real.  what i think i need to do is make a web page with all the nice things listed in a short form (one line each).  that will be a lot of work.

Easy-peasy:

~ $ pydoc -w os os.path
wrote os.html
wrote os.path.html
I think this command comes with the python.

Wow, I didn't know it. It gets even better :D
Try out:
$ pydoc -p 8080

This will run a web server on port 8080 and you can read the docs in the browser at http://localhost:8080
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Making Zip file of a file and Directory Nasir 2 985 Oct-07-2022, 02:01 PM
Last Post: Nasir

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020