Every line of 'convert string to tuple python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
30 def as_tuple(value): 31 ''' 32 Smart cast value to tuple by splittng the input on ",". 33 ''' 34 if isinstance(value, tuple): 35 return value 36 return tuple(as_list(value))
223 def make_tuple(value): 224 """Return value as tuple. 225 226 >>> make_tuple((1, 2, 3)) 227 (1, 2, 3) 228 >>> make_tuple('abc') 229 ('a', 'b', 'c') 230 >>> make_tuple([4, 5, 6]) 231 (4, 5, 6) 232 >>> make_tuple(None) 233 (None,) 234 235 """ 236 if isinstance(value, tuple): 237 return value 238 if isinstance(value, Sequence): 239 return tuple(value) 240 return (value,)
22 def to_tuple(x): 23 return x.as_tuple() if hasattr(x, 'as_tuple') else x