[issue36017] test_grp

2019-02-17 Thread Mathijs Brands
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

[issue36017] test_grp

2019-02-17 Thread Mathijs Brands
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

Re: list comprehention

2006-01-25 Thread Mathijs
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

Re: list comprehention

2006-01-23 Thread Mathijs
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

Re: list comprehention

2006-01-23 Thread Mathijs
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

Re: list comprehention

2006-01-23 Thread Mathijs
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,

Re: list comprehention

2006-01-23 Thread Mathijs
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

list comprehention

2006-01-19 Thread Mathijs
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,