New submission from Mathijs Brands :
# Choose a non-existent gid.
fakegid = 4127
while fakegid in bygids:
fakegid = (fakegid * 3) % 0x1
self.assertRaises(KeyError, grp.getgrgid, fakegid)
When a Linux system is configured to use LDAP for user and group
Change by Mathijs Brands :
--
components: Tests
nosy: mjbrands
priority: normal
severity: normal
status: open
title: test_grp
type: behavior
versions: Python 3.7
___
Python tracker
<https://bugs.python.org/issue36
23 jan 2006 ta (Steven D'Aprano) shuo le:
This is the type of solution I was hoping to see: one-liners, with no
use of local variables.
Because you like unreadable, incomprehensible, unmaintainable code?
For practical use: no! But I'm just learning python and to understand
sets/lists/dicts
Op 19 jan 2006 vond [EMAIL PROTECTED] :
another approach:
ref = [2,2,4,1,1]
lis = [2,2,5,2,4]
len([ref.pop(ref.index(x)) for x in lis if x in ref])
This is the type of solution I was hoping to see: one-liners, with no use
of local variables. As Tim Chase already wrote, it has only one
Op 19 jan 2006 vond Peter Otten [EMAIL PROTECTED] :
sum(min(list.count(n), ref.count(n)) for n in set(ref))
Is that it?
Seems like this is it! Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Op 19 jan 2006 vond Paddy [EMAIL PROTECTED]:
answer = [ val for val in set(ref) for x in
range(min(lst.count(val), ref.count(val)))] answer
[2, 2, 4]
I don't think it's correct. Your algoritm with the ref and lst below gives
3 as answer. The answer should have been 2 (1,3).
ref=[3, 3, 1, 1,
Op 20 jan 2006 vond Duncan Booth [EMAIL PROTECTED]:
Or in other words, define a function to return a dictionary containing
a count of the number of occurrences of each element in the list (this
assumes that the list elements are hashable). Then you just add up the
values in the test list
Hi,
Python beginner here and very much enjoying it. I'm looking for a
pythonic way to find how many listmembers are also present in a reference
list. Don't count duplicates (eg. if you already found a matching member
in the ref list, you can't use the ref member anymore).
Example1:
ref=[2,