Python Forum
Compare two lists (with intersections).
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compare two lists (with intersections).
#1
Compare two lists (with intersections).

model:
reserve_period = sa.Column(sa.String, nullable=True)
the format of saving in the database
['2022-07-04', '2022-07-05', '2022-07-06', '2022-07-07']

filter:
async def period_item(
    request
):
    async with async_session() as session:
        rtf = await in_rtf(request)
        reserve = rtf.reserve_period
        result = await session.execute(
            select(Item, Rent)
            .join(
                ReserveTimeFor.something_item,
            )
            .where(Rent.rent_belongs == Item.id)
            .where(
                ReserveTimeFor.reserve_period != reserve # this is temporary
            )
        )
        obj_item = result.scalars().unique()
        return obj_item

    await engine.dispose()
#
How to embed, put filtering
#
period = set(reserve_period) & set(reserve)
if not period:
    return period
return False
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,387 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Compare Two Lists and Replace Items In a List by Index nagymusic 2 2,898 May-10-2020, 05:28 AM
Last Post: deanhystad
  Lists first item is a number however i cant compare it with an int getting syntax err Sutsro 4 2,436 Apr-22-2020, 10:22 AM
Last Post: Sutsro
  how to compare a list to a list of lists kevthew 1 1,811 Dec-22-2019, 11:43 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,295 Mar-20-2019, 08:01 PM
Last Post: stillsen
  loop to compare lists KHas 1 1,692 Jan-31-2019, 10:17 PM
Last Post: Larz60+
  Lists-compare lists elhetch 7 5,703 Mar-01-2017, 02:50 PM
Last Post: buran

Forum Jump:

User Panel Messages

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