[Tutor] OS lib creating an directory using an absolute path.

nathan tech nathan-tech at hotmail.com
Sat Feb 6 05:51:58 EST 2021


Heya,


myself I tend to break it down and use os.mkdir on each.

A quick google however revealed this question from stackoverflow which I 
didn't know, and may be of particular use.

https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python


HTH!

Nathan

On 06/02/2021 10:33, mhysnm1964 at gmail.com wrote:
> All,
>
>   
>
> I am using the os library. If I have a directory structure with any missing
> directory (folders), then the os.mkdir function fails as it cannot find the
> filenamefilename. For example:
>
>   
>
> Current directory structure is:
>
>   
>
> C:\books  with nothing inside.
>
>   
>
> The path I am wanting to create is:
>
>   
>
> E:\books\a\anne rice
>
>   
>
> Yes, I could break the path and check each level of the directory. But I was
> wondering if there was any other method to do this. As if you do this at
> Windows 10 command line:
>
>   
>
> Mkdir E:\books\"a\anne rice"
>
>   
>
> The 'a' directory plus 'anne rice' is also created.
>
>   
>
> I hope this makes sense. Python 3.8 under windows 10.
>
>   
>
> Sean
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&data=04%7C01%7C%7C889add95823f43b4533008d8ca8ad53f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637482044923551659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rPTuEiR6BEHkSsajTb25n0Yu8PLP0JA05UJNkrFzj7w%3D&reserved=0


More information about the Tutor mailing list