本文整理匯總了Python中UserString.MutableString方法的典型用法代碼示例。如果您正苦於以下問題:Python UserString.MutableString方法的具體用法?Python UserString.MutableString怎麽用?Python UserString.MutableString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserString
的用法示例。
在下文中一共展示了UserString.MutableString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_extended_set_del_slice
# 需要導入模塊: import UserString [as 別名]
# 或者: from UserString import MutableString [as 別名]
def test_extended_set_del_slice(self):
indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100)
orig = string.ascii_letters + string.digits
for start in indices:
for stop in indices:
# Use indices[1:] when MutableString can handle real
# extended slices
for step in (None, 1, -1):
s = self.type2test(orig)
L = list(orig)
# Make sure we have a slice of exactly the right length,
# but with (hopefully) different data.
data = L[start:stop:step]
data.reverse()
L[start:stop:step] = data
s[start:stop:step] = "".join(data)
self.assertEqual(s, "".join(L))
del L[start:stop:step]
del s[start:stop:step]
self.assertEqual(s, "".join(L))
示例2: test_mutablestring_removal
# 需要導入模塊: import UserString [as 別名]
# 或者: from UserString import MutableString [as 別名]
def test_mutablestring_removal(self):
# UserString.MutableString has been removed in 3.0.
import UserString
# UserString tests may have already triggered this warning
reset_module_registry(UserString)
with warnings.catch_warnings():
warnings.filterwarnings("error", ".*MutableString",
DeprecationWarning)
self.assertRaises(DeprecationWarning, UserString.MutableString)
示例3: test_main
# 需要導入模塊: import UserString [as 別名]
# 或者: from UserString import MutableString [as 別名]
def test_main():
with warnings.catch_warnings():
warnings.filterwarnings("ignore", ".*MutableString has been removed",
DeprecationWarning)
warnings.filterwarnings("ignore",
".*__(get|set|del)slice__ has been removed",
DeprecationWarning)
test_support.run_unittest(UserStringTest, MutableStringTest)
示例4: isstringtype
# 需要導入模塊: import UserString [as 別名]
# 或者: from UserString import MutableString [as 別名]
def isstringtype( obj ):
"""Is the object of a Python string type?"""
if isinstance(obj, basestring):
return True
# Must also check for some other pseudo-string types
import types, UserString
return isinstance(obj, types.StringTypes) \
or isinstance(obj, UserString.UserString) \
or isinstance(obj, UserString.MutableString)
# ----------------------------------------------------------------------
# Numeric helpers