How do i put my users in a dictionary, then access the key value pairs uid, name and shell?
from dataclasses import dataclass
@dataclass()
class User:
uid: str
name: str
shell: str
user_dict = {}
user1 = User('1', '2', '3')
user_dict[user1.uid] = user1
print(user_dict)
print(user_dict['1'].name)
print(user_dict['1'].shell)
Output:
{'1': User(uid='1', name='2', shell='3')}
2
3
Thank you for the response, but i meant my the users with pwd.getpwall.
Answers are limited by the quality of the question that's asked, please read the links in my signature.