Python Forum
Placing directory in a function
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Placing directory in a function
#2
(Jul-04-2018, 03:39 AM)mmaz67 Wrote: how do i go one level up to /in_file directory?
You can use os.chdir("..")
Can also use pathlib which has a parent method.
>>> from pathlib import Path, PurePath
>>> 
>>> p = PurePath(Path.cwd())
>>> p
PurePosixPath('/home/mint')
>>> p.parent
PurePosixPath('/home')
Reply


Messages In This Thread
Placing directory in a function - by mmaz67 - Jul-04-2018, 03:39 AM
RE: Placing directory in a function - by snippsat - Jul-04-2018, 06:27 AM
RE: Placing directory in a function - by mmaz67 - Jul-04-2018, 06:57 AM
RE: Placing directory in a function - by volcano63 - Jul-04-2018, 09:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What default directory does "open" function draw from? Athenaeum 4 3,873 Oct-07-2017, 06:15 AM
Last Post: Skaperen
  placing module level statements into def michaelcollier 7 6,007 May-01-2017, 03:42 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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