Re: Is there a function that returns common elements in multiple lists

2022-01-25 Thread Sam Chaffy
You can use sets On Tue, Jan 25, 2022 at 7:47 AM bnmng wrote: > Hello, > > Is there a built in function that compares two or more lists and returns > elements common to all? > > like this: > > def in_both( list_a, list_b ): > list_c=[] > for value in list_a: > if value in list_b: > list_c.append

Re: Is there a function that returns common elements in multiple lists

2022-01-25 Thread bnmng
Thank you. That set.intersection with list conversion seems like the way to go. On your second point, well taken. I'll keep that in mind for future Python questions On Tuesday, January 25, 2022 at 7:46:58 AM UTC-5 bnmng wrote: > Hello, > > Is there a built in function that compares two or mo

Re: Is there a function that returns common elements in multiple lists

2022-01-25 Thread Kasper Laudrup
On 25/01/2022 13.46, bnmng wrote: Hello, Is there a built in function that compares two or more lists and returns elements common to all? The intersect member function almost does that, just combine in with converting your list to a set: https://datagy.io/python-intersection-between-list

intermittent migration error

2022-01-25 Thread Ben Cail
Hello, I ran into an intermittent migration issue on Django 4.x and PostgreSQL. The migrations work fine on Django 3.2.x, but intermittently fail on Django 4.x with the following exception: django.db.utils.ProgrammingError: constraint "polls_questioncontribution_base_question_id_25bfb2a8_fk"

Re: Lack of tutorials and explanations about channels

2022-01-25 Thread lone...@gmail.com
Well, I did it. I frankensteined my way to a working Django 3.0+ and Channels 3.0 demo project! Here is where I went. I started at: https://testdriven.io/blog/django-channels/#add-channels. I cannot stress this enough, I started at the add-channels section! During my time in following the i

Is there a function that returns common elements in multiple lists

2022-01-25 Thread bnmng
Hello, Is there a built in function that compares two or more lists and returns elements common to all? like this: def in_both( list_a, list_b ): list_c=[] for value in list_a: if value in list_b: list_c.append(value) return list_c Or this: def in_all(list_of_lists): list_a = list_of_lists.po