Why are tuples constructed from differently initialized sets equal?

At first glance, it appears that x should always equal y, because two sets constructed from the same elements are always equal: >>> x = set([1, “a”, “b”, “c”, “z”, “f”]) >>> y = set([“a”, “b”, “c”, “z”, “f”, 1]) >>> x {1, ‘z’, ‘a’, ‘b’, ‘c’, ‘f’} >>> y {1, ‘z’, ‘a’, ‘b’, ‘c’, … Read more

How to compare a list of lists/sets in python?

So you want the difference between two lists of items. first_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘3c3c3c’, 3333]] secnd_list = [[‘Test.doc’, ‘1a1a1a’, 1111], [‘Test2.doc’, ‘2b2b2b’, 2222], [‘Test3.doc’, ‘8p8p8p’, 9999], [‘Test4.doc’, ‘4d4d4d’, 4444]] First I’d turn each list of lists into a list of tuples, so as tuples are hashable (lists are not) … Read more

How do I convert a tuple of tuples to a one-dimensional list using list comprehension? [duplicate]

it’s typically referred to as flattening a nested structure. >>> tupleOfTuples = ((1, 2), (3, 4), (5,)) >>> [element for tupl in tupleOfTuples for element in tupl] [1, 2, 3, 4, 5] Just to demonstrate efficiency: >>> import timeit >>> it = lambda: list(chain(*tupleOfTuples)) >>> timeit.timeit(it) 2.1475738355700913 >>> lc = lambda: [element for tupl in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)