Python Forum
function that returns a list of dictionaries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function that returns a list of dictionaries
#3
(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?
Reply


Messages In This Thread
RE: function that returns a list of dictionaries - by nostradamus64 - May-06-2021, 09:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort a list of dictionaries by the only dictionary key Calab 2 676 Apr-29-2024, 04:38 PM
Last Post: Calab
  Access list of dictionaries britesc 4 1,144 Jul-26-2023, 05:00 AM
Last Post: Pedroski55
  function returns dataframe as list harum 2 1,489 Aug-13-2022, 08:27 PM
Last Post: rob101
  function accepts infinite parameters and returns a graph with those values edencthompson 0 890 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  convert List with dictionaries to a single dictionary iamaghost 3 2,904 Jan-22-2021, 03:56 PM
Last Post: iamaghost
  Creating a list of dictionaries while iterating pythonnewbie138 6 3,350 Sep-27-2020, 08:23 PM
Last Post: pythonnewbie138
  Recursive function returns None, when True is expected akar 0 3,434 Sep-07-2020, 07:58 PM
Last Post: akar
  Help accessing elements of list of dictionaries Milfredo 6 2,902 Sep-07-2020, 01:32 AM
Last Post: Milfredo
  Accessing values in list of dictionaries pythonnewbie138 2 2,175 Aug-02-2020, 05:02 PM
Last Post: pythonnewbie138
  how does .join work with list and dictionaries gr3yali3n 7 3,372 Jul-07-2020, 09:36 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020