fork(1) download
  1. import re
  2.  
  3. def mytype(v):
  4. s = str(v)
  5. list_regex = re.compile(r'(?P<list>\[[^]]+\])|(?P<float>\d*\.\d+)|(?P<int>\d+)|(?P<string>[a-zA-Z]+)')
  6. return r"<type '%s'>" % list_regex.search(s).lastgroup
  7.  
  8. print(mytype(5))
  9. print(mytype(5.5))
  10. print(mytype(.99))
  11. print(mytype("hsjjsRHJSK"))
  12. print(mytype([1.1,2,3.2,4,5]))
Success #stdin #stdout 0.02s 27728KB
stdin
Standard input is empty
stdout
<type 'int'>
<type 'float'>
<type 'float'>
<type 'string'>
<type 'list'>