User Tools

Site Tools


python:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
python:index [2014/07/19 22:02] tkbletscpython:index [2014/07/19 22:02] tkbletsc
Line 121: Line 121:
  
 <code=python> <code=python>
-def parse_table(table_tsv, xform=None):+def recognize_type(v): 
 +    if re.match(r'\d+$',v): 
 +        return int(v) 
 +    if re.match(r'\d+\.\d*$',v): 
 +        return float(v) 
 +    return v 
 +     
 +def parse_table(table_tsv, xform=recognize_type):
     table_rows = table_tsv.strip().split("\n")     table_rows = table_tsv.strip().split("\n")
  
Line 163: Line 170:
  
 </code> </code>
- 
  
python/index.txt · Last modified: 2014/07/20 17:48 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki