1👍
This is a bit round about, but I imagine it would work.
Assuming a debian distro, you could try adding the specific command that you want to a script, then chmod/chown it to restrict access to root only.
chown root:root /path/to/script.sh
chmod 755 /path/to/script.sh
Next, run sudo visudo
and add the following:
normalusername ALL = NOPASSWD: /home/usr/path/to/script.sh
Reboot, write some code in python to execute your script as a normal user, and I imagine you’d be good to go.
Your python code would look like this:
import os
os.system("sudo path/to/script.sh")
Source:stackexchange.com