Python Forum
Get anything before arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get anything before arguments
#3
Thanks for your reply. This prints /path/to/Python37-32/python.exe or /path/to/Python38-32/python.exe when I use python and py in command line, respectively. But that still doesn't tell whether the user entered python or py?

(May-18-2021, 02:01 AM)BashBedlam Wrote: This should do the trick.

import psutil
import os
my_process = psutil.Process (os.getpid())
print (my_process.cmdline())
Reply


Messages In This Thread
Get anything before arguments - by Robotguy - May-17-2021, 11:16 PM
RE: Get anything before arguments - by BashBedlam - May-18-2021, 02:01 AM
RE: Get anything before arguments - by Robotguy - May-18-2021, 11:17 PM
RE: Get anything before arguments - by BashBedlam - May-19-2021, 01:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 4,030 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

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