Python Forum
Get Current Directory From ShortCut.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Current Directory From ShortCut.
#2
Example tested works.
Data.txt:
Output:
42
# meow.py
with open(r'G:\div_code\PyProj\Assets\Data.txt') as f:
    print(f.read())

input('Press any key to quit')
Output:
42
So giving absolute path to Data.txt and other option is the package way with importlib.resources
Also running code from shortcut the window will disapred fast,so add input() to stop it so can se result.
Reply


Messages In This Thread
Get Current Directory From ShortCut. - by Oshadha - Jul-30-2022, 12:56 PM
RE: Get Current Directory From ShortCut. - by snippsat - Jul-30-2022, 04:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Windows install does not create .exe, shortcut,etc to open hammer 4 2,131 May-05-2022, 12:33 PM
Last Post: hammer
  How to read python shortcut target profile directory of Chrome Ink file sunny9495 1 1,761 Apr-12-2022, 06:12 PM
Last Post: sunny9495
  portable way to get current directory Skaperen 5 3,327 Jun-12-2019, 01:16 PM
Last Post: Skaperen
  current directory issue saisankalpj 1 2,475 Nov-12-2018, 12:06 PM
Last Post: buran
  CWD (Current working directory) pcsailor 5 4,844 Nov-11-2018, 10:14 AM
Last Post: Larz60+
  how to create desktop shortcut shlomi27 3 4,162 Aug-23-2018, 09:26 PM
Last Post: buran
  How to run atom python script on idle press on keyboard shortcut. sonjoypall 2 5,224 Feb-07-2018, 07:51 AM
Last Post: buran
  Importing module from outside of the current directory Annie 4 4,710 Mar-21-2017, 11:13 PM
Last Post: Annie

Forum Jump:

User Panel Messages

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