Hello everyone, i want to create a function that returns a list of dictionaries with my users
in Python. I dont want it to print out something, i want to use this module for another script.
How do i go about it? thanks in advance.
# result.py
from my_record import foo
def bar():
print(f'The car vaules is <{foo()[1].get("car")}>')
bar()
Output:
The car vaules is <641>
Look at at how
modules work is the simplest way to use use
import
.
So here is both files in same folder.
This is file i import from.
# my_record.py
def foo():
my_lst = [
{"foo": 12, "bar": 14},
{"moo": 52, "car": 641},
{"doo": 6, "tar": 84},
]
return my_lst
Here a
post where explain more a packages(a way to organize more files/folders).
(May-06-2021, 09:42 PM)snippsat Wrote: [ -> ]# result.py
from my_record import foo
def bar():
print(f'The car vaules is <{foo()[1].get("car")}>')
bar()
Output:
The car vaules is <641>
Look at at how modules work is the simplest way to use use import
.
So here is both files in same folder.
This is file i import from.
# my_record.py
def foo():
my_lst = [
{"foo": 12, "bar": 14},
{"moo": 52, "car": 641},
{"doo": 6, "tar": 84},
]
return my_lst
Here a post where explain more a packages(a way to organize more files/folders).
Thank you, and if i use the module pwd and systemd how could i get info about my users UID, name, shell(login) and if they are logged in or not with an asterisk symbol to symbolise it?