I'm fairly new to scripting in Python. I'm looking for suggestions on improving any of the following in the below script: my coding style, performance, readability, commenting, or anything else.
"""
META
Author: James Nicholson
Date: 8/16/2013
DESCRIPTION
This script takes a list of groups from a text file and creates a new text file
in CSV format that contains group members in the below format:
group_name1,user_name1
group_name1,user_name2
etc...
VARIABLES
server = 'domain name'
glist = 'path to text file containing desired groups'
"""
# Import the win32 module needed for accessing groups and members
import win32net
# Set server name and group_list text file variables
server = # enter server name here
group_list = 'groups.txt'
grps = []
# Loop over lines in group_list and store group names in a list
with open(group_list, 'rb') as my_groups:
for line in my_groups:
grps.append(line.rstrip('\r\n'))
# Loop over groups and store members in desired format in new text file 'groups_members_output.txt'
with open('groups_members_output.txt', 'wb') as blank_file:
for group in grps:
usrs = win32net.NetGroupGetUsers(server,group,0)
for user in usrs[0]:
blank_file.write('{},{}\r\n'.format(group,user['name']))