當前位置: 首頁>>代碼示例>>Python>>正文


Python types.XList類代碼示例

本文整理匯總了Python中Naked.toolshed.types.XList的典型用法代碼示例。如果您正苦於以下問題:Python XList類的具體用法?Python XList怎麽用?Python XList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了XList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_xlist_remove_dupes_int

 def test_xlist_remove_dupes_int(self):
     xl = XList([1, 2, 2, 3, 3, 3], {'first_attr': 1})
     nodupe = xl.remove_duplicates()
     self.assertEqual(type(nodupe), type(XList(['test', 'again'])))
     self.assertEqual(nodupe.count(1), 1)
     self.assertEqual(nodupe.count(2), 1)
     self.assertEqual(nodupe.count(3), 1)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:7,代碼來源:test_TYPES_c.py

示例2: test_xlist_multi_wildcard_match

 def test_xlist_multi_wildcard_match(self):
     xl = XList(['many', 'tom', 'Many'], {'first_attr': 1})
     nl = xl.multi_wildcard_match('m*|t*')
     self.assertTrue(len(nl) == 2)
     self.assertTrue('many' in nl)
     self.assertTrue('tom' in nl)
     self.assertFalse('Many' in nl)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:7,代碼來源:test_TYPES_c.py

示例3: test_xlist_difference

 def test_xlist_difference(self):
     xl = XList([1 , 2, 3], {'first_attr': 1})
     xl2 = XList([2, 4, 5])
     diff = xl.difference(xl2)  # returns items in XList that are not in parameter list/XList as set
     self.assertTrue(1 in diff)
     self.assertTrue(3 in diff)
     self.assertFalse(2 in diff)
     self.assertFalse(4 in diff)
     self.assertFalse(5 in diff)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:9,代碼來源:test_TYPES_c.py

示例4: test_xlist_intersection

 def test_xlist_intersection(self):
     xl = XList([1 , 2, 3], {'first_attr': 1})
     xl2 = XList([2, 4, 5])
     inter = xl.intersection(xl2) # returns items in both XList and parameter list/XList
     self.assertTrue(2 in inter)
     self.assertFalse(1 in inter)
     self.assertFalse(3 in inter)
     self.assertFalse(4 in inter)
     self.assertFalse(5 in inter)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:9,代碼來源:test_TYPES_c.py

示例5: test_xlist_map_items

 def test_xlist_map_items(self):
     def cap_val(xlist_item):
         return xlist_item.upper()
     xl = XList(['one', 'two', 'three'], {'first_attr': 1})
     nl = xl.map_to_items(cap_val)
     self.assertTrue('ONE' in nl)
     self.assertTrue('TWO' in nl)
     self.assertTrue('THREE' in nl)
     self.assertFalse('one' in nl)
     self.assertFalse('two' in nl)
     self.assertFalse('three' in nl)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:11,代碼來源:test_TYPES_c.py

示例6: test_xlist_conditional_map_items

        def test_xlist_conditional_map_items(self):
            def true_a(xdict_key):
                return xdict_key.startswith('a')

            def cap_val(xdict_val):
                return xdict_val.upper()

            xl = XList(['all', 'many', 'none'], {'first_attr': 1})
            nl = xl.conditional_map_to_items(true_a, cap_val)
            self.assertTrue('ALL' in nl)
            self.assertFalse('all' in nl)
            self.assertFalse('MANY' in nl)
            self.assertFalse('NONE' in nl)
            self.assertTrue(nl[0] == 'ALL')
            self.assertTrue(nl[1] == 'many')
            self.assertTrue(nl[2] == 'none')
開發者ID:chrisidefix,項目名稱:naked,代碼行數:16,代碼來源:test_TYPES_c.py

示例7: test_xlist_count_case_insensitive_withother

 def test_xlist_count_case_insensitive_withother(self):
     xl = XList(['MANY', 1, 'many'], {'first_attr': 1})
     nl = xl.count_ci('Many')
     self.assertTrue(nl == 2)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:4,代碼來源:test_TYPES_c.py

示例8: test_xlist_map_items_noreturn_value

 def test_xlist_map_items_noreturn_value(self):
     def no_return(xlist_val):
         x = 1
     xl = XList(['one', 'two', 'three'], {'first_attr': 1})
     nl = xl.map_to_items(no_return)
     self.assertTrue(nl[0] == None)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:6,代碼來源:test_TYPES_c.py

示例9: test_xlist_surround_two_strings

 def test_xlist_surround_two_strings(self):
     xl = XList(['one', 'two', 'three'], {'first_attr': 1})
     nl = xl.surround('<p>', '</p>')
     self.assertTrue('<p>one</p>' in nl)
     self.assertTrue('<p>two</p>' in nl)
     self.assertTrue('<p>three</p>' in nl)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:6,代碼來源:test_TYPES_c.py

示例10: test_xlist_postfix_unicode_char

 def test_xlist_postfix_unicode_char(self):
     xl = XList(['one', 'two', 'three'], {'first_attr': 1})
     nl = xl.postfix('ত')
     self.assertTrue('oneত' in nl)
     self.assertTrue('twoত' in nl)
     self.assertTrue('threeত' in nl)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:6,代碼來源:test_TYPES_c.py

示例11: test_xlist_wildcard_match

 def test_xlist_wildcard_match(self):
     xl = XList(['MANY', 'many', 'Many'], {'first_attr': 1})
     nl = xl.wildcard_match('m*')
     self.assertTrue(len(nl) == 1)
     self.assertEqual(nl[0], 'many')
開發者ID:chrisidefix,項目名稱:naked,代碼行數:5,代碼來源:test_TYPES_c.py

示例12: test_xlist_shuffle

 def test_xlist_shuffle(self):
     xl = XList([1 , 2, 3], {'first_attr': 1})
     nl = xl.random_sample(2)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:3,代碼來源:test_TYPES_c.py

示例13: test_xlist_count_dupes_string_twodupe

 def test_xlist_count_dupes_string_twodupe(self):
     xl = XList(['test', 'test', 'another', 'another', 'last', 'last'], {'first_attr': 1})
     dupes = xl.count_duplicates()
     self.assertEqual(dupes, 3)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:4,代碼來源:test_TYPES_c.py

示例14: test_xlist_count_dupes_int_twodupe

 def test_xlist_count_dupes_int_twodupe(self):
     xl = XList([1, 2, 2, 3, 3, 3], {'first_attr': 1})
     dupes = xl.count_duplicates()
     self.assertEqual(dupes, 3)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:4,代碼來源:test_TYPES_c.py

示例15: test_xlist_sum_float

 def test_xlist_sum_float(self):
     xl = XList([1.2 , 2.5, 3.1], {'first_attr': 1})
     total = xl.sum()
     self.assertAlmostEqual(total, 6.8)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:4,代碼來源:test_TYPES_c.py


注:本文中的Naked.toolshed.types.XList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。