In the following program why is pwd.getpwuid returning my user and group names followed by three commas? Where ar ethe commas coming from?


import os, stat, pwd

dirList = os.listdir()

permissions = (stat.filemode(os.stat(dirList[1]).st_uid))

string = permissions + ' '
string = string + dirList[1]


temp = os.stat(dirList[1])

temp2 = pwd.getpwuid(temp.st_uid)
Member Avatar

Your code seems to work for me on OSX 10.9.1 with Python 3.3.3. I see a regular pwd.struct_passwd() tuple-like object returned from pwd.getpwuid(). I don't see the user, group and three commas stuff.

What OS platform are you running on? Have you confirmed the userId returned by temp.st_uid has a valid/complete passwd file entry? Perhaps that might point the way to why the behavior is different?