Terry J. Reedy added the comment: The docs for pwd and spwd modules specify that some items are strings and others are ints. Null strings should be '' and 'null' ints must be negative since 0 can be a valid item. It happens that all but 2 pwd items are strings and all but 2 spwd items are ints. The 2 pwd int items are uid and gid, which I believe are never missing, so you never encounter -1 for them. Similarly, the 2 spwd str items are nam and pwd, which I believe are not missing either, so you never encounter '' for them. Otherwise, your val != -1 test would not work.
I believe the following expression will work for spwd (and even pwd) (I cannot test on Windows ;-). ':'.join((str(val) if val != -1 else '') for val in rec) ---------- nosy: +terry.reedy resolution: -> invalid status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17676> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com