[Tutor] iPython check if user running script is root user (Linux)

Alan Gauld alan.gauld at btinternet.com
Fri Jun 1 00:29:17 CEST 2012


On 31/05/12 23:21, Dave wrote:
> Hi. What is the right way to have an iPython script check to see if the
> user is currently root?

I don;t know anything much about ipython but so far as IO know its just 
a shell on standard python so:

os.getuid()

should work.
In general if you are trying to replace bash with python look at the
os, shutil, glob, os.path modules as a first port of call.

hth

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list